diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 2957ec83b..6701de97b 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -166,6 +166,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks MissingWorldPhysicsOwnerCannotAdvanceShips, TractorRampsAndPullsThroughYmirWithoutTeleportingCargo, PickupIsCapacityCheckedExactlyOnceAndExpires, + TradePurchaseDerivesAcceptanceFromDaemonState, StationBodiesCannotConsumePickups, PickupShieldContactCollectsOrBounces, YmirRestartDoesNotReplayConsumedPickupContact, @@ -3043,7 +3044,6 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var forbiddenCommand = AetheriaRuntimeDaemonCommandDocument.Create(AetheriaRuntimeDaemonCommandKinds.PickUpLoot, "pilot", "pickup-smoke", 0, "zone.0.entity.0"); forbiddenCommand.CommandId = "pickup-command-forbidden"; forbiddenCommand.TargetEntityKey = "zone.0.entity.0"; - forbiddenCommand.LootPickup.PickupIndex = 7; var forbidden = AetheriaRuntimeDaemonOperations.Execute(run, [forbiddenCommand], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog }); Require(forbidden.RejectedCommandIds.Contains(forbiddenCommand.CommandId), "client pickup commands must not own cargo collection"); @@ -3115,6 +3115,73 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "daemon lifetime owner must emit authoritative pickup expiry event"); } + private static void TradePurchaseDerivesAcceptanceFromDaemonState() + { + var ore = CatalogItem("trade-ore"); ore.Price = 40; ore.Volume = 1; + var cargoBay = CatalogItem("trade-cargo-bay"); cargoBay.InteriorOccupiedCells = 10; + var catalog = new AetheriaRuntimeCatalogSnapshot([ore, cargoBay], [], []); + var station = Entity(0, 0, "station"); + station.Kind = "station"; + station.CargoContents = [Cargo((ore.ItemKey, 10, 2, 3))]; + station.DockingBayAssignments = [1]; + station.ChildEntityIndices = [1]; + var ship = Entity(1, 0, "player"); + ship.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 } + }]; + ship.CargoContents = [Cargo()]; + var zone = new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [station, ship] }; + var run = new AetheriaRuntimeRunCheckpointCommit + { + RunId = "trade-authority-smoke", + CurrentZoneIndex = 0, + CurrentEntityKey = "zone.0.entity.1", + Credits = 5000, + Zones = [zone] + }; + var command = AetheriaRuntimeDaemonCommandDocument.Create( + AetheriaRuntimeDaemonCommandKinds.TradePurchase, + "pilot", + "trade-authority-smoke", + 1, + run.CurrentEntityKey); + command.TradePurchase.ItemKey = ore.ItemKey; + command.TradePurchase.Quantity = 5; + command.TradePurchase.StationCargoIndex = 0; + command.TradePurchase.TargetCargoIndex = 0; + command.TradePurchase.SourceX = 2; + command.TradePurchase.SourceY = 3; + command.TradePurchase.PurchaseKind = "docked_ship"; + command.TradePurchase.UnitPrice = -999; + command.TradePurchase.TotalPrice = -999; + command.TradePurchase.StationEntityKey = "forged-station"; + command.TradePurchase.TargetEntityKey = "forged-target"; + command.TradePurchase.CreatesDockedShip = true; + + Require(AetheriaRuntimeRunCheckpointCommit.TryParseEntityKey(run.CurrentEntityKey, out _, out _), + "trade smoke current entity key must be daemon-resolvable"); + RequireEqual(10, AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(ship, catalog, ore.ItemKey, 0), + "trade smoke cargo fixture must have room for the requested commodity"); + var daemonUnitPrice = AetheriaRuntimeDaemonTradeItemQueries.TradeItemValue( + ore, + station.CargoContents[0].Items[0].Item, + catalog.TradeValueSettings).Price; + Require(daemonUnitPrice > 0, "trade smoke daemon catalog price must be positive"); + + var result = AetheriaRuntimeDaemonOperations.Execute( + run, + [command], + new AetheriaRuntimeDaemonOperationContext { Catalog = catalog }); + + Require(result.AppliedCommandIds.Contains(command.CommandId), + "daemon must accept a valid commodity purchase regardless of forged compatibility opinions"); + RequireEqual(5000 - daemonUnitPrice * 5, run.Credits, + "daemon catalog price must own trade credit mutation"); + RequireEqual(5, CargoQuantity(ship, ore.ItemKey), "daemon cargo capacity and placement must own delivery"); + RequireEqual(2, zone.Entities.Count, "forged ship-creation opinion must not materialize an entity"); + } + private static void StationBodiesCannotConsumePickups() { var hull = CatalogItem("station-filter-hull"); hull.HullCapacity = PerformanceStat(1); diff --git a/Aetheria.State.Freeze/Program.cs b/Aetheria.State.Freeze/Program.cs index 54c3246a2..249ea460d 100644 --- a/Aetheria.State.Freeze/Program.cs +++ b/Aetheria.State.Freeze/Program.cs @@ -347,14 +347,9 @@ static IReadOnlyList BuildRefitCommands() command.PositionY = 0; command.ScalarValue = 25; command.TextValue = "reactor-fuel"; - command.TradePurchase.PurchaseKind = "cargo"; command.TradePurchase.ItemKey = "reactor-fuel"; command.TradePurchase.Quantity = 1; - command.TradePurchase.UnitPrice = 25; - command.TradePurchase.TotalPrice = 25; - command.TradePurchase.StationEntityKey = station; command.TradePurchase.StationCargoIndex = 0; - command.TradePurchase.TargetEntityKey = actor; command.TradePurchase.TargetCargoIndex = 0; command.TradePurchase.SourceX = 1; command.TradePurchase.SourceY = 0; @@ -399,11 +394,6 @@ static IReadOnlyList BuildRefitCommands() command.PositionX = -40; command.PositionY = 0; command.PositionZ = -35; - command.LootPickup.ItemKey = "loose-salvage"; - command.LootPickup.Quantity = 2; - command.LootPickup.PositionX = -40; - command.LootPickup.PositionY = 0; - command.LootPickup.PositionZ = -35; }), Command("refit-008-restore-loadout", AetheriaRuntimeDaemonCommandKinds.RestoreLoadout, actor, command => { diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 616ddc5aa..94e7fedf9 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -622,10 +622,10 @@ Console.WriteLine("Inventory entity rename authority: UI sends daemon operations Console.WriteLine("Weapon group authority: UI sends daemon operations for assignments instead of checkpoint rewrites"); Console.WriteLine("Action-bar binding authority: Unity owns local input bindings; activations send daemon operations"); Console.WriteLine("Inventory transfer authority: UI transfer and drag/drop send daemon operations"); -Console.WriteLine("Loot pickup authority: collision pickup sends daemon operations instead of local pickup disposal"); +Console.WriteLine("Loot pickup authority: daemon cargo collection occurs exactly once from an authenticated Ymir contact fact"); Console.WriteLine("Entity destruction authority: hull-death observers send daemon operations instead of local graph deletion"); Console.WriteLine("Dropped pickup state: daemon frames carry typed dropped-pickup snapshots and keyed live lowering"); -Console.WriteLine("Trade purchase authority: UI buy requests send daemon operations instead of checkpoint rewrites"); +Console.WriteLine("Trade purchase authority: UI requests item and placement; daemon derives price, station, product kind, capacity, and ship creation"); Console.WriteLine("Inventory loadout restore authority: UI restore requests send daemon operations instead of local mutation"); Console.WriteLine("Docked current-ship authority: UI selection requests send daemon operations instead of checkpoint rewrites"); @@ -6605,8 +6605,7 @@ static void RequireTradeItemValuesUseRuntimeQueries(string root) "public string TierColorHex => TradeValue.TierColorHex", "x.TypedItem.TryGetSimpleCommodityCategory(", "x.TypedItem.TryGetCompoundCommodityCategory(", - "x.TypedItem.TryGetHardpointType(", - "row.TypedItem.TryGetSimpleCommodityCategory(out SimpleCommodityCategory _)" + "x.TypedItem.TryGetHardpointType(" }; var missingTradeMenuSymbols = requiredTradeMenuSymbols .Where(symbol => !tradeMenu.Contains(symbol, StringComparison.Ordinal)) @@ -10971,7 +10970,6 @@ static void RequireTypedDaemonCommandPayloads(string root) "public enum AetheriaRuntimeDaemonCommandKinds", "public sealed class AetheriaRuntimeCargoTransferCommand", "public sealed class AetheriaRuntimeTradePurchaseCommand", - "public sealed class AetheriaRuntimeLootPickupCommand", "public sealed class AetheriaRuntimeLoadoutRestoreCommand", "public sealed class AetheriaRuntimeEquipmentTransferCommand", "public sealed class AetheriaRuntimeStoreItemCommand" @@ -10986,6 +10984,41 @@ static void RequireTypedDaemonCommandPayloads(string root) string.Join(", ", missingPayloadTypes)); } + if (!daemonDocuments.Contains("public sealed class AetheriaRuntimeLootPickupCommand", StringComparison.Ordinal) || + !daemonDocuments.Contains("public AetheriaRuntimeLootPickupCommand LootPickup { get; set; }", StringComparison.Ordinal) || + !daemonDocuments.Contains("Serialization tombstone", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "The retired loot-pickup payload must remain only as an explicit serialization tombstone for persisted command compatibility."); + } + + var forbiddenRetiredCommandOpinionUses = new[] + { + ".LootPickup.", + "purchase.PurchaseKind", + "purchase.UnitPrice", + "purchase.TotalPrice", + "purchase.StationEntityKey", + "purchase.TargetEntityKey", + "purchase.CreatesDockedShip", + "command.TradePurchase.PurchaseKind", + "command.TradePurchase.UnitPrice", + "command.TradePurchase.TotalPrice", + "command.TradePurchase.StationEntityKey", + "command.TradePurchase.TargetEntityKey", + "command.TradePurchase.CreatesDockedShip" + }; + var liveCommandImplementation = daemonClient + "\n" + daemonOperationsSource; + var survivingRetiredCommandOpinionUses = forbiddenRetiredCommandOpinionUses + .Where(symbol => liveCommandImplementation.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (survivingRetiredCommandOpinionUses.Length > 0) + { + throw new InvalidOperationException( + "Retired compatibility fields still influence live loot or trade command behavior: " + + string.Join(", ", survivingRetiredCommandOpinionUses)); + } + if (daemonDocuments.Contains("public sealed class AetheriaRuntimeActionBarBindingCommand", StringComparison.Ordinal)) { throw new InvalidOperationException( @@ -11066,7 +11099,6 @@ static void RequireTypedDaemonCommandPayloads(string root) "return Send((client, frame) => client.TransferCargoItem(", "command.CargoTransfer.OriginEntityKey", "ReadPayloadString(request, \"itemKey\", \"\")", - "command.LootPickup.ItemKey", "command.LoadoutRestore.TemplateName", "command.EquipmentTransfer.SourceKind", "command.StoreItem.SourceEquipmentIndex" @@ -11513,6 +11545,7 @@ static void RequireDaemonVersePublication(string root) var daemonHostProjectPath = Path.Combine(root, "Aetheria.State.Daemon", "Aetheria.State.Daemon.csproj"); var daemonHostProgramPath = Path.Combine(root, "Aetheria.State.Daemon", "Program.cs"); var daemonZoneGeneratorPath = Path.Combine(root, "Aetheria.State.Daemon", "AetheriaDaemonZoneGenerator.cs"); + var daemonLoadoutGeneratorPath = Path.Combine(root, "Aetheria.State.Daemon", "AetheriaDaemonLoadoutGenerator.cs"); var documentRegistryPath = Path.Combine(root, "Aetheria.State", "AetheriaDocumentRegistry.cs"); var stateNodePath = Path.Combine(root, "Aetheria.State", "AetheriaStateNode.cs"); var runtimeSurfaceDocumentsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeSurfaceDocuments.cs"); @@ -11547,6 +11580,7 @@ static void RequireDaemonVersePublication(string root) daemonHostProjectPath, daemonHostProgramPath, daemonZoneGeneratorPath, + daemonLoadoutGeneratorPath, documentRegistryPath, stateNodePath, runtimeSurfaceDocumentsPath, @@ -11589,6 +11623,7 @@ static void RequireDaemonVersePublication(string root) var daemonHostProject = File.ReadAllText(daemonHostProjectPath); var daemonHostProgram = File.ReadAllText(daemonHostProgramPath); var daemonZoneGenerator = File.ReadAllText(daemonZoneGeneratorPath); + var daemonLoadoutGenerator = File.ReadAllText(daemonLoadoutGeneratorPath); var documentRegistry = File.ReadAllText(documentRegistryPath); var stateNode = File.ReadAllText(stateNodePath); var runtimeSurfaceDocuments = File.ReadAllText(runtimeSurfaceDocumentsPath); @@ -12093,7 +12128,6 @@ static void RequireDaemonVersePublication(string root) "AetheriaRuntimeStatRecipeSurfaceBuilder.BuildFromCatalog(catalog)", "AetheriaRuntimeTradeValuePolicySurfaceBuilder.BuildFromCatalog(catalog)", "AetheriaRuntimeDaemonEditorSurfaceBuilder.Build", - "SoaView = soaView", "ProviderAdvertisement = providerAdvertisement", "Health = health", "CommandBoundary = commandBoundary", @@ -12102,7 +12136,7 @@ static void RequireDaemonVersePublication(string root) "ObservedCommands", "AccountedCommandIds", "frame.AccountedCommandIds = accountedBeforeTick", - "ObservedCommandCount = observedCommands.Length", + "ObservedCommandCount = observedCommandCount", "PublicationSource = \"daemon-published\"", "Transport = \"cultmesh-managed\"", "CommandBoundaryPath = AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary.ToString()" @@ -12145,8 +12179,8 @@ static void RequireDaemonVersePublication(string root) } if (daemonZoneGenerator.Contains("fallbackCargo", StringComparison.Ordinal) || - !daemonZoneGenerator.Contains("Build(string entityKind, string factionKey, IReadOnlyList scenarioCargo)", StringComparison.Ordinal) || - !daemonZoneGenerator.Contains("if (scenarioCargo != null && scenarioCargo.Count > 0)", StringComparison.Ordinal)) + !daemonLoadoutGenerator.Contains("IReadOnlyList scenarioCargo)", StringComparison.Ordinal) || + !daemonLoadoutGenerator.Contains("foreach (var key in scenarioCargo ?? Array.Empty())", StringComparison.Ordinal)) { throw new InvalidOperationException( "Daemon zone generation must treat declared scenario cargo as authored state, not as a catalog-generation fallback."); @@ -12167,9 +12201,7 @@ static void RequireDaemonVersePublication(string root) "StarbridgeScenario = starbridgeScenario", "StarbridgeSession = starbridgeSession", "BuildPublications = buildPublications", - "new AetheriaVerseDiscoveryHost(node)", - "discoveryHost.Update(", - "PublishDaemonApiDocumentsAsync(node, options, result)", + "PublishDaemonApiDocumentsAsync(node, options, soaPublisher, result", "node.MutableDocument(AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest)", "node.MutableDocument(AetheriaRuntimeVerseRecordKeys.DaemonProviderAdvertisement)", "node.MutableDocument(AetheriaRuntimeVerseRecordKeys.DaemonHealth)", @@ -12203,11 +12235,6 @@ static void RequireDaemonVersePublication(string root) "node.MutableDocument(AetheriaStateNode.PlayerSettingsSurfaceKey)", "node.MutableDocument(AetheriaStateNode.ProviderAdvertisementSurfaceKey)", "AetheriaEveSurfaceDocuments.BuildProviderAdvertisement(verseHost, node.StatePath, updatedAtUtc)", - "static EveProviderAdvertisementDocument BuildOdinProviderAdvertisement(", - "static CultNetDocumentPutRawMessage CreateOdinRawPut(", - "EveProviderAdvertisementDocument.SchemaId", - "EveProviderAdvertisementDocument canonical", - "MessagePackSerializer.Serialize(payload)", "AetheriaEveSurfaceDocuments.BuildOperationsSurface(eveStatus, verseHost, runtimeSession)", "AetheriaEveSurfaceDocuments.BuildPlayerSettingsSurface(playerSettings, playerSettingsUpdatedAt)", "Role = \"verse-daemon\"", @@ -12221,7 +12248,7 @@ static void RequireDaemonVersePublication(string root) if (missingDaemonHostSymbols.Length > 0) { throw new InvalidOperationException( - "Aetheria.State.Daemon no longer has Odin/VoidBot-shaped Verse daemon host authority: " + + "Aetheria.State.Daemon no longer exposes its direct CultMesh daemon host authority: " + string.Join(", ", missingDaemonHostSymbols)); } @@ -12322,7 +12349,7 @@ static void RequireDaemonVersePublication(string root) } if (!daemonTickBlock.Contains("if (buildPublications)", StringComparison.Ordinal) || - !daemonTickBlock.Contains("PublishDaemonApiDocumentsAsync(node, options, result)", StringComparison.Ordinal)) + !daemonTickBlock.Contains("PublishDaemonApiDocumentsAsync(node, options, soaPublisher, result", StringComparison.Ordinal)) { throw new InvalidOperationException( "Daemon ticks must publish API cadence documents through managed AetheriaStateNode pointers."); @@ -12488,8 +12515,10 @@ static void RequireDaemonVersePublication(string root) var requiredGameSurfaceSymbols = new[] { - "public const string SurfaceId = \"aetheria.game\"", - "public const string TuiSurfaceId = \"aetheria.game.tui\"", + "public const string PilotSurfaceId = \"aetheria.pilot\"", + "public const string CommanderSurfaceId = \"aetheria.starbridge.commander\"", + "public const string SurfaceId = PilotSurfaceId", + "public const string TuiSurfaceId = \"aetheria.pilot.tui\"", "AetheriaRuntimeDaemonFrameDocument frame", "AetheriaRuntimeDaemonHealthDocument health", "AetheriaRuntimeDaemonCommandBoundaryDocument commandBoundary", @@ -12499,8 +12528,6 @@ static void RequireDaemonVersePublication(string root) "AetheriaRuntimeDaemonStateRefs.CurrentEntityName", "AetheriaRuntimeDaemonStateRefs.CurrentTargetName", "\"game.daemon\"", - "\"aetheria.daemon.game.starbridge\"", - "\"Starbridge Session\"", "\"Station Stock\"", "\"Wave Forecast\"", "\"Runtime Roles\"", @@ -15979,7 +16006,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) var requiredDaemonNavigationAuthoritySymbols = new[] { "ApplyEnterWormholeIntent(run, command, context.Intents)", - "ApplyTowToStationIntent(run, command, context.Intents)", + "ApplyTowToStation(run, command, context.DockingDistance)", "MoveEntityToZone(run, actor, command.TargetZoneIndex", "run.CurrentZoneIndex = targetZoneIndex", "run.CurrentEntityKey = movedEntityKey", @@ -16371,14 +16398,14 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) { "TowToStation", "AetheriaRuntimeDaemonCommandKinds.TowToStation", - "ApplyTowToStationIntent", - "out var stationZoneIndex", - "out var station", - "var destinationX = station.PositionX;", - "var destinationY = station.PositionZ;", - "MoveEntityToZone(run, actor, stationZoneIndex, destinationX, destinationY, out var movedEntityKey)", - "intents.Towing.Add", - "AetheriaRuntimeDaemonTowIntent", + "ApplyTowToStation(", + "double attachmentDistance", + "towing.ChildEntityIndices", + "command.TextValue, \"attach\"", + "attachmentDistance * attachmentDistance", + "command.TextValue, \"detach\"", + "zone.Orbits =", + "station.OrbitKey = orbitKey", "public CultMeshOperationReceipt TowToStation(string stationEntityKey)" }; @@ -16594,8 +16621,7 @@ static void RequireThermalPresentationAssetAuthority(string root) "[\"presentationRole\"] = entry.Ref.Metadata.TryGetValue", "IEveUnityThermalPresentationAssetSink", "assets.Heatstroke as VolumeProfile", - "_death.weight = frame.DeathWeight", - "b112acb34d1e2561f1e770a9088bd0123e6614ab" + "_death.weight = frame.DeathWeight" }; var body = assets + daemon + builder + migrator + sink + manifest; var missing = required.Where(symbol => !body.Contains(symbol, StringComparison.Ordinal)).ToArray(); @@ -16885,15 +16911,15 @@ static void RequireUnityDoesNotCallSharedSimulationTicks(string root) "StepCombat(run, zone, entities, intents, deltaSeconds, settings, worldPhysics, catalog,", "AetheriaRuntimeEquippedBehaviorQueries.Find(entity, catalog, AetheriaRuntimeBehaviorKinds.InstantWeapon)", "EnsureWeaponState(", - "CommitWeaponRound(attacker, weapon)", + "CommitWeaponRound(attacker, weapon, catalog)", "weapon.State.BurstRemaining = weapon.BurstCount", "weapon.State.BurstTimer += deltaSeconds", "weapon.SingleAmmoBurst", "weapon.reload.started", "weapon.reload.completed", "AetheriaRuntimeCargoTransactions.TryRemoveQuantity(", - "CommitEnergy(entity, weapon.Energy)", - "CommitShotResolution(run, zone, attacker, target, weapon, shotId, frameId)", + "CommitEnergy(entity, catalog, weapon.Energy)", + "CommitShotResolution(run, zone, attacker, target, weapon, shotId, frameId, catalog, settings)", "PreparePhysicalPayloads(zone, byIndex, deltaSeconds)", "worldPhysics.StepPhysicalPayloads(", "Kind = \"physical-payload.contact\"" @@ -16915,9 +16941,9 @@ static void RequireUnityDoesNotCallSharedSimulationTicks(string root) [ymirWorldPhysicsPath] = new[] { "public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDisposable", - "public YmirSession WorldSession { get; }", - "public YmirSession PayloadSession { get; }", - "state.PayloadSession.Step(new YmirStepSessionCommand(", + "public YmirSession WorldSession { get; } = worldSession", + "public YmirSession? PayloadSession { get; set; }", + "var stepped = payloadSession.Step(new YmirStepSessionCommand(", "state.WorldSession.CastCircle(new YmirSessionCircleCastQuery(", "state.WorldSession.OverlapCircle(new YmirSessionCircleOverlapQuery(", "PhysicalPayloadPrefix + payload.PayloadId", @@ -17271,16 +17297,6 @@ static void RequireUnityDoesNotCallSharedSimulationTicks(string root) throw new InvalidOperationException( "Electron document decoding must not fabricate fallback Aetheria asset refs; daemon-authored documents and CultMesh CDN own asset identity."); } - if (!rtsClientApp.Contains("aetheria-cdn://asset?uri=", StringComparison.Ordinal) || - !rtsClientApp.Contains("uri.startsWith(\"cultmesh://\")", StringComparison.Ordinal) || - !rtsElectronMain.Contains("protocol.handle(assetProtocol", StringComparison.Ordinal) || - !rtsElectronMain.Contains("aetheriaClient.assetBlob(uri)", StringComparison.Ordinal) || - !rtsElectronCultMesh.Contains("cultMeshCdnAssetBlobSchemaId", StringComparison.Ordinal) || - !rtsElectronCultMesh.Contains("public async assetBlob(uri: string)", StringComparison.Ordinal)) - { - throw new InvalidOperationException( - "Electron Eve lowering must resolve CultMesh asset refs through the daemon CultMesh CDN protocol bridge."); - } if (rtsElectronCultMesh.Contains("buildViewportDocumentFromFrame(await this.fetchLatestFrameDocument()", StringComparison.Ordinal) || rtsElectronCultMesh.Contains("buildObjectsViewportDocumentFromFrame(await this.fetchLatestFrameDocument()", StringComparison.Ordinal) || rtsElectronCultMesh.Contains("buildGravityViewportDocumentFromFrame(await this.fetchLatestFrameDocument()", StringComparison.Ordinal) || @@ -17291,13 +17307,6 @@ static void RequireUnityDoesNotCallSharedSimulationTicks(string root) throw new InvalidOperationException( "Electron queries must fetch daemon-authored managed documents, not rebuild field/view/selection/inventory documents from daemonFrame."); } - if (rtsElectronCultMesh.Contains("switch (request?.surfaceId)", StringComparison.Ordinal) || - rtsElectronCultMesh.Contains("case \"aetheria.", StringComparison.Ordinal) || - !rtsElectronCultMesh.Contains("return surfaceId ? `eve:surface:${surfaceId}` : defaultEveSurfaceRecordKey;", StringComparison.Ordinal)) - { - throw new InvalidOperationException( - "Electron Eve surface loading must not carry a hardcoded Aetheria panel catalog; Eve surface ids resolve through daemon-authored surface records."); - } if (rtsLocalDocuments.Contains("buildViewportDocumentFromFrame", StringComparison.Ordinal) || rtsLocalDocuments.Contains("buildObjectsViewportDocumentFromFrame", StringComparison.Ordinal) || rtsLocalDocuments.Contains("buildGravityViewportDocumentFromFrame", StringComparison.Ordinal) || @@ -19864,7 +19873,8 @@ static void RequireTradePurchaseRequestAuthority(string root) var requiredDaemonShipPurchaseSymbols = new[] { "ApplyCreateDockedShipPurchase(", - "purchase.CreatesDockedShip", + "var createsDockedShip = !string.IsNullOrWhiteSpace(typedItem.HullType)", + "ApplyCreateDockedShipPurchase(run, dockParentKey, itemKey, out var purchasedShipKey)", "run.CurrentEntityKey = purchasedShipKey", "HullItemKey = itemKey" }; diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index f94383d26..de4bdb91e 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -4278,12 +4278,6 @@ public class DaemonRuntimeDocumentTests command.PositionY = 11; command.PositionZ = 12; command.ScalarValue = 1; - command.LootPickup.ItemKey = "loot-cell"; - command.LootPickup.PickupIndex = 7; - command.LootPickup.Quantity = 1; - command.LootPickup.PositionX = 10; - command.LootPickup.PositionY = 11; - command.LootPickup.PositionZ = 12; var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { command }); @@ -4432,18 +4426,18 @@ public class DaemonRuntimeDocumentTests command.TargetEntityKey = "zone.0.entity.1"; command.TextValue = "ore"; command.ScalarValue = 200; - command.TradePurchase.PurchaseKind = "commodity"; command.TradePurchase.ItemKey = "ore"; command.TradePurchase.Quantity = 5; - command.TradePurchase.UnitPrice = 0; - command.TradePurchase.TotalPrice = 0; - command.TradePurchase.StationEntityKey = "zone.0.entity.0"; command.TradePurchase.StationCargoIndex = 0; - command.TradePurchase.TargetEntityKey = "zone.0.entity.1"; command.TradePurchase.TargetCargoIndex = 0; command.TradePurchase.SourceX = 2; command.TradePurchase.SourceY = 3; - command.TradePurchase.CreatesDockedShip = false; + command.TradePurchase.PurchaseKind = "docked_ship"; + command.TradePurchase.UnitPrice = -999; + command.TradePurchase.TotalPrice = -999; + command.TradePurchase.StationEntityKey = "forged-station"; + command.TradePurchase.TargetEntityKey = "forged-target"; + command.TradePurchase.CreatesDockedShip = true; var result = AetheriaRuntimeDaemonOperations.Execute( run, @@ -4479,9 +4473,7 @@ public class DaemonRuntimeDocumentTests "zone.0.entity.1"); command.TradePurchase.ItemKey = "ore"; command.TradePurchase.Quantity = 1; - command.TradePurchase.StationEntityKey = "zone.0.entity.0"; command.TradePurchase.StationCargoIndex = 0; - command.TradePurchase.TargetEntityKey = "zone.0.entity.1"; command.TradePurchase.TargetCargoIndex = 0; command.TradePurchase.SourceX = 2; command.TradePurchase.SourceY = 3; @@ -4528,17 +4520,17 @@ public class DaemonRuntimeDocumentTests command.TargetEntityKey = "zone.0.entity.1"; command.TextValue = "starter-hull"; command.ScalarValue = 300; - command.TradePurchase.PurchaseKind = "docked_ship"; command.TradePurchase.ItemKey = "starter-hull"; command.TradePurchase.Quantity = 1; - command.TradePurchase.UnitPrice = 300; - command.TradePurchase.TotalPrice = 300; - command.TradePurchase.StationEntityKey = "zone.0.entity.1"; command.TradePurchase.StationCargoIndex = 0; - command.TradePurchase.TargetEntityKey = "zone.0.entity.1"; command.TradePurchase.SourceX = 4; command.TradePurchase.SourceY = 5; - command.TradePurchase.CreatesDockedShip = true; + command.TradePurchase.PurchaseKind = "commodity"; + command.TradePurchase.UnitPrice = 0; + command.TradePurchase.TotalPrice = 0; + command.TradePurchase.StationEntityKey = "forged-station"; + command.TradePurchase.TargetEntityKey = "forged-target"; + command.TradePurchase.CreatesDockedShip = false; var result = AetheriaRuntimeDaemonOperations.Execute( run, diff --git a/Assets/Scripts/UI/Menu/TradeMenu.cs b/Assets/Scripts/UI/Menu/TradeMenu.cs index ef28ce958..fd74b470f 100644 --- a/Assets/Scripts/UI/Menu/TradeMenu.cs +++ b/Assets/Scripts/UI/Menu/TradeMenu.cs @@ -409,101 +409,40 @@ public class TradeMenu : MonoBehaviour return; } - var createsDockedShip = !string.IsNullOrWhiteSpace(row.TypedItem.HullType); - if (createsDockedShip && - !string.Equals(row.TypedItem.HullType, nameof(HullType.Ship), StringComparison.Ordinal)) - { - ShowUnableToBuy("Unsupported hull purchase!"); - return; - } - - RequestTradePurchase(row, quantity, createsDockedShip); + RequestTradePurchase(row, quantity); } private void RequestTradePurchase( TradeRow row, - int quantity, - bool createsDockedShip) + int quantity) { if (row?.Stock == null || string.IsNullOrWhiteSpace(row.ItemKey) || - quantity <= 0 || - row.Price < 0) + quantity <= 0) { return; } - var totalPrice = (long)quantity * row.Price; - if (totalPrice > int.MaxValue) - return; - - var stationRefit = StationRefitSnapshot(); - var stationEntityKey = stationRefit?.DockParentEntityKey ?? ""; var stationCargoIndex = row.Stock.CargoBayIndex; var sourcePosition = new int2(row.Stock.X, row.Stock.Y); - if (string.IsNullOrWhiteSpace(stationEntityKey) || - stationCargoIndex < 0 || + if (stationCargoIndex < 0 || sourcePosition.x < 0 || sourcePosition.y < 0) { return; } - var targetEntityKey = _targetCargoEntityKey ?? ""; - var targetCargoIndex = _targetCargoIndex; - - if (createsDockedShip) - { - if (!TryResolveCurrentDockingTargetEntityKey(out targetEntityKey)) - { - return; - } - - targetCargoIndex = -1; - } - else if (string.IsNullOrWhiteSpace(targetEntityKey) || - targetCargoIndex < 0) - { - return; - } - - var purchaseKind = createsDockedShip - ? "docked_ship" - : row.TypedItem.TryGetSimpleCommodityCategory(out SimpleCommodityCategory _) - ? "commodity" - : "crafted"; - TrySubmitOperation( operations => operations.TradePurchase( - purchaseKind, row.ItemKey, quantity, - row.Price, - (int)totalPrice, - stationEntityKey, stationCargoIndex, - targetEntityKey, - targetCargoIndex, + _targetCargoIndex, sourcePosition.x, - sourcePosition.y, - createsDockedShip), + sourcePosition.y), "trade purchase"); } - private bool TryResolveCurrentDockingTargetEntityKey(out string targetEntityKey) - { - targetEntityKey = ""; - if (!TryResolveCurrentDocking(out var docking) || - docking.IsDocked != true || - string.IsNullOrWhiteSpace(docking.DockParentEntityKey)) - { - return false; - } - - targetEntityKey = docking.DockParentEntityKey; - return true; - } - private AetheriaRuntimeStationRefitDocument StationRefitSnapshot() { try diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs index be1d2c88c..cb2f4b3b1 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs @@ -164,31 +164,19 @@ namespace GameCult.Aetheria.State.Verse hasDestinationPosition); public CultMeshOperationReceipt TradePurchase( - string purchaseKind, string itemKey, int quantity, - int unitPrice, - int totalPrice, - string stationEntityKey, int stationCargoIndex, - string targetEntityKey, int targetCargoIndex, int sourceX, - int sourceY, - bool createsDockedShip) => + int sourceY) => _operations.TradePurchase( - purchaseKind, itemKey, quantity, - unitPrice, - totalPrice, - stationEntityKey, stationCargoIndex, - targetEntityKey, targetCargoIndex, sourceX, - sourceY, - createsDockedShip); + sourceY); public CultMeshOperationReceipt RestoreLoadout( string dockedEntityKey, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs index 00c742566..6efc70053 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs @@ -641,6 +641,8 @@ namespace GameCult.Aetheria.State.Verse [Key(22)] public AetheriaRuntimeTradePurchaseCommand TradePurchase { get; set; } = new AetheriaRuntimeTradePurchaseCommand(); + // Serialization tombstone: retained so old command documents remain readable. + // The daemon rejects PickUpLoot and no client operation writes this payload. [Key(23)] public AetheriaRuntimeLootPickupCommand LootPickup { get; set; } = new AetheriaRuntimeLootPickupCommand(); @@ -850,6 +852,8 @@ namespace GameCult.Aetheria.State.Verse [MessagePackObject] public sealed class AetheriaRuntimeTradePurchaseCommand { + // Keys 0, 3, 4, 5, 7, and 11 are serialization tombstones. The daemon + // derives product kind, price, station, target, and ship creation. [Key(0)] public string PurchaseKind { get; set; } = ""; @@ -885,6 +889,7 @@ namespace GameCult.Aetheria.State.Verse [Key(11)] public bool CreatesDockedShip { get; set; } + } [MessagePackObject] diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs index f13477428..9aa539f07 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs @@ -456,38 +456,24 @@ namespace GameCult.Aetheria.State.Verse internal AetheriaRuntimeDaemonCommandEnvelope TradePurchase( AetheriaRuntimeDaemonFrameDocument? frame, - string purchaseKind, string itemKey, int quantity, - int unitPrice, - int totalPrice, - string stationEntityKey, int stationCargoIndex, - string targetEntityKey, int targetCargoIndex, int sourceX, - int sourceY, - bool createsDockedShip) + int sourceY) { var command = Create(AetheriaRuntimeDaemonCommandKinds.TradePurchase, frame); - command.TargetEntityKey = targetEntityKey ?? ""; command.EquipmentIndex = targetCargoIndex; command.PositionX = sourceX; command.PositionY = sourceY; - command.ScalarValue = totalPrice; command.TextValue = itemKey ?? ""; - command.TradePurchase.PurchaseKind = purchaseKind ?? ""; command.TradePurchase.ItemKey = itemKey ?? ""; command.TradePurchase.Quantity = quantity; - command.TradePurchase.UnitPrice = unitPrice; - command.TradePurchase.TotalPrice = totalPrice; - command.TradePurchase.StationEntityKey = stationEntityKey ?? ""; command.TradePurchase.StationCargoIndex = stationCargoIndex; - command.TradePurchase.TargetEntityKey = targetEntityKey ?? ""; command.TradePurchase.TargetCargoIndex = targetCargoIndex; command.TradePurchase.SourceX = sourceX; command.TradePurchase.SourceY = sourceY; - command.TradePurchase.CreatesDockedShip = createsDockedShip; return Send(command); } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs index 85686efb3..5ed9238d4 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs @@ -948,7 +948,6 @@ namespace GameCult.Aetheria.State.Verse { if (quantity != 1 || !HasAvailableDockingBay(dockParent)) return false; - purchase.TargetEntityKey = dockParentKey; if (!TryRemoveCargoItemQuantity( stationEntity, stationCargoIndex, @@ -958,7 +957,7 @@ namespace GameCult.Aetheria.State.Verse 1, out var purchasedHull)) return false; - if (!ApplyCreateDockedShipPurchase(run, purchase, out var purchasedShipKey)) + if (!ApplyCreateDockedShipPurchase(run, dockParentKey, itemKey, out var purchasedShipKey)) { AddCargoItem(stationEntity, stationCargoIndex, purchasedHull); return false; @@ -1075,13 +1074,13 @@ namespace GameCult.Aetheria.State.Verse private static bool ApplyCreateDockedShipPurchase( AetheriaRuntimeRunCheckpointCommit run, - AetheriaRuntimeTradePurchaseCommand purchase, + string dockParentKey, + string itemKey, out string purchasedShipKey) { purchasedShipKey = ""; - var itemKey = purchase.ItemKey ?? ""; if (string.IsNullOrWhiteSpace(itemKey) || - !TryResolveEntity(run, purchase.TargetEntityKey, out var zoneIndex, out var parentIndex, out var parent)) + !TryResolveEntity(run, dockParentKey, out var zoneIndex, out var parentIndex, out var parent)) { return false; } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs index 0d050ac9d..8a5bb82ce 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs @@ -294,33 +294,21 @@ public sealed class AetheriaRuntimeDaemonOperationsClient } public CultMeshOperationReceipt TradePurchase( - string purchaseKind, string itemKey, int quantity, - int unitPrice, - int totalPrice, - string stationEntityKey, int stationCargoIndex, - string targetEntityKey, int targetCargoIndex, int sourceX, - int sourceY, - bool createsDockedShip) + int sourceY) { return Send((client, frame) => client.TradePurchase( frame, - purchaseKind, itemKey, quantity, - unitPrice, - totalPrice, - stationEntityKey, stationCargoIndex, - targetEntityKey, targetCargoIndex, sourceX, - sourceY, - createsDockedShip)); + sourceY)); } public CultMeshOperationReceipt RestoreLoadout( @@ -511,18 +499,12 @@ public sealed class AetheriaRuntimeDaemonOperationsClient ReadPayloadString(request, "taskId", "")), AetheriaRuntimeDaemonCommandKinds.TradePurchase => client.TradePurchase( frame, - "", ReadPayloadString(request, "itemKey", ""), (int)ReadPayloadDouble(request, "quantity", 1), - 0, - 0, - ReadPayloadString(request, "stationEntityKey", ""), (int)ReadPayloadDouble(request, "stationCargoIndex", -1), - ReadPayloadString(request, "targetEntityKey", ""), (int)ReadPayloadDouble(request, "targetCargoIndex", -1), (int)ReadPayloadDouble(request, "sourceX", int.MinValue), - (int)ReadPayloadDouble(request, "sourceY", int.MinValue), - false), + (int)ReadPayloadDouble(request, "sourceY", int.MinValue)), _ => AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless( client, frame, diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 0ad43592b..05034ca2c 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1747,10 +1747,11 @@ First Aetheria surfaces to publish: `InventoryPanel` may request a selected docked player ship and update the button color, but the daemon owns `CurrentEntity`, `DockingBay.DockedShip`, and the typed checkpoint. - - Done: route loot pickup through typed daemon operations. `ShieldManager` - may detect the collision and destroy the world pickup after a successful - commit, but it no longer stores items into cargo bays directly; the daemon - owns the cargo mutation and typed run checkpoint. + - Done: delete client-owned loot pickup submission. Tractor power influences + Ymir motion, but only an authenticated Ymir Begin contact fact can ask the + daemon pickup transaction to mutate cargo or remove a pickup. Unity + collision callbacks and the retired serialized command payload have no + writer authority. - Done: route entity destruction through typed daemon operations. `EntityInstance` observes hull death and may spawn the local destruction effect, but the daemon owns equipment/cargo drop decisions, zone entity @@ -2271,8 +2272,12 @@ membership, and the daemon owns the group mutation and checkpoint. Inventory double-click transfer follows the same rule, and drag/drop placement now shares that commit family: UI requests cargo/equipment movement, and the daemon owns the move and checkpoint. Trade -purchases follow the same rule: UI requests the purchase, and the daemon owns -credit changes, cargo transfer, ship creation, and checkpoint. Runtime loadout +purchases follow the same rule: UI requests only item, quantity, stock slot, +and destination bay. The daemon derives the dock parent, current catalog price, +product kind, capacity, hull-vs-cargo result, credit changes, cargo transfer, +ship creation, and checkpoint. Historical price, station, target, purchase-kind, +and `CreatesDockedShip` fields remain serialization tombstones only; live clients +do not write them and daemon operations do not read them. Runtime loadout restore follows the same rule: UI requests restoration, and the daemon owns instantiation, credits, dock assignment, current entity, and checkpoint. Docked current-ship selection follows the same rule: UI requests selection, and the