Restore fossil docking transactions

This commit is contained in:
Meta Vens 2026-07-17 00:17:12 +01:00
commit 93d4d44ffc
11 changed files with 588 additions and 124 deletions

View file

@ -167,6 +167,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
DaemonSimulationTreatsYmirHitAsPresentationOnly,
ProjectileContactCannotKill,
MissingWorldPhysicsOwnerCannotAdvanceShips,
DockingUsesRealBaysAndFossilUndockRules,
TractorRampsAndPullsThroughYmirWithoutTeleportingCargo,
PickupIsCapacityCheckedExactlyOnceAndExpires,
TradePurchaseDerivesAcceptanceFromDaemonState,
@ -211,6 +212,187 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
RunCheck(check);
}
private static void DockingUsesRealBaysAndFossilUndockRules()
{
var catalog = new AetheriaRuntimeCatalogSnapshot(
[
CatalogItem("dock-cockpit", new AetheriaRuntimeBehaviorPayload(0, "Cockpit", 0, [])),
CatalogItem("dock-thruster", new AetheriaRuntimeBehaviorPayload(0, "Thruster", 0, [])),
CatalogItem("dock-drive", new AetheriaRuntimeBehaviorPayload(0, "AetherDrive", 0, [])),
CatalogItem("dock-reactor", new AetheriaRuntimeBehaviorPayload(0, "Reactor", 0, []))
], [], []);
var context = new AetheriaRuntimeDaemonOperationContext { Catalog = catalog };
static AetheriaRuntimeEntitySnapshotCommit DockTarget(int index, double x, bool hasBay)
{
var target = Entity(index, x, "station");
target.PositionZ = 0;
if (hasBay)
{
target.DockingBays = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "dock-bay" }
}];
target.DockingBayAssignments = [-1];
target.DockingBayContents = [Cargo()];
}
return target;
}
var actor = Entity(0, 0, "player");
var ineligible = DockTarget(1, 5, false);
var outOfRange = DockTarget(2, 30, true);
var firstEligible = DockTarget(3, 20, true);
var nearerButLater = DockTarget(4, 10, true);
var selectionRun = new AetheriaRuntimeRunCheckpointCommit
{
RunId = "dock-selection-smoke",
CurrentZoneIndex = 0,
CurrentEntityKey = "zone.0.entity.0",
Zones = [new AetheriaRuntimeZoneSnapshotCommit
{
ZoneIndex = 0,
Entities = [actor, ineligible, outOfRange, firstEligible, nearerButLater]
}]
};
var dock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.DockNearest,
"pilot",
"dock-selection-smoke",
0,
selectionRun.CurrentEntityKey);
dock.ScalarValue = 100;
var dockResult = AetheriaRuntimeDaemonOperations.Execute(selectionRun, [dock], context);
RequireEqual(1, dockResult.AppliedCommandIds.Count,
"DockNearest must accept the first entity with a real empty bay inside the fossil radius");
RequireEqual(actor.EntityIndex, firstEligible.DockingBayAssignments.Single(),
"docking must use the first eligible entity in stable zone order instead of the closest entity");
RequireEqual(-1, nearerButLater.DockingBayAssignments.Single(),
"a later closer station must not override the fossil first-eligible selection");
RequireEqual(0, ineligible.DockingBayAssignments.Count,
"docking must not manufacture a bay assignment on an entity with no docking-bay equipment");
RequireEqual(-1, outOfRange.DockingBayAssignments.Single(),
"a client scalar must not widen the daemon-owned fossil docking radius");
AetheriaRuntimeRunCheckpointCommit DockedRun(
IReadOnlyList<string> itemKeys,
bool bayHasCargo = false)
{
var ship = Entity(0, 7, "player");
ship.PositionZ = 9;
ship.VelocityX = 3;
ship.VelocityY = -4;
ship.DirectionX = 0.6;
ship.DirectionY = 0.8;
ship.Equipment = itemKeys.Select(itemKey => new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{
ItemKey = itemKey,
Durability = 1,
Enabled = true
}
}).ToArray();
var station = DockTarget(1, 7, true);
station.PositionZ = 9;
station.ChildEntityIndices = [0];
station.DockingBayAssignments = [0];
station.DockingBayContents = [bayHasCargo
? Cargo(("forgotten-cargo", 1, 0, 0))
: Cargo()];
return new AetheriaRuntimeRunCheckpointCommit
{
RunId = "undock-parity-smoke",
CurrentZoneIndex = 0,
CurrentEntityKey = "zone.0.entity.0",
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ship, station] }]
};
}
AetheriaRuntimeDaemonOperationResult RejectUndock(
IReadOnlyList<string> itemKeys,
string expectedReason,
bool bayHasCargo = false)
{
var run = DockedRun(itemKeys, bayHasCargo);
var command = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Undock,
"pilot",
"undock-parity-smoke",
0,
run.CurrentEntityKey);
command.CommandId = $"undock:{expectedReason}";
var result = AetheriaRuntimeDaemonOperations.Execute(run, [command], context);
RequireEqual(expectedReason, result.RejectedCommandReasons[command.CommandId],
"undock rejection must retain the exact daemon-owned fossil reason");
Require(run.Zones[0].Entities[1].DockingBayAssignments.Contains(0),
"a rejected undock must leave parentage and bay assignment untouched");
return result;
}
RejectUndock(["dock-thruster", "dock-reactor"],
AetheriaRuntimeDaemonRejectionReasons.MissingCockpit);
RejectUndock(["dock-cockpit", "dock-reactor"],
AetheriaRuntimeDaemonRejectionReasons.MissingPropulsion);
RejectUndock(["dock-cockpit", "dock-thruster"],
AetheriaRuntimeDaemonRejectionReasons.MissingReactor);
var cargoRejected = RejectUndock(
["dock-cockpit", "dock-thruster", "dock-reactor"],
AetheriaRuntimeDaemonRejectionReasons.DockingBayCargoNotEmpty,
bayHasCargo: true);
var cargoFrame = AetheriaRuntimeDaemonFrameDocument.Create(
cargoRejected.Run, "daemon", "session", 4, 0.08, 0.02);
cargoFrame.RejectedCommandIds = cargoRejected.RejectedCommandIds;
cargoFrame.RejectedCommandReasons = cargoRejected.RejectedCommandReasons;
var cargoCommand = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Undock,
"pilot",
"undock-parity-smoke",
0,
cargoRejected.Run.CurrentEntityKey);
cargoCommand.CommandId = "undock:docking-bay-cargo-not-empty";
var fact = AetheriaRuntimeCommittedCommandFactDocument.FromRejectedCommand(
cargoFrame, cargoCommand, "aetheria.local");
RequireEqual(AetheriaRuntimeDaemonRejectionReasons.DockingBayCargoNotEmpty, fact.RejectionReason,
"the committed command fact must carry the daemon-owned undock rejection reason");
var receipt = AetheriaRuntimeDaemonReceiptProjector.Project(
fact, AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId);
Require(receipt.State == "denied" &&
receipt.Message.Contains(AetheriaRuntimeDaemonRejectionReasons.DockingBayCargoNotEmpty,
StringComparison.Ordinal),
"the generic Eve receipt must expose the exact rejection reason without client reconstruction");
var successRun = DockedRun(["dock-cockpit", "dock-drive", "dock-reactor"]);
var successShip = successRun.Zones[0].Entities[0];
var poseBefore = (
successShip.PositionX,
successShip.PositionZ,
successShip.VelocityX,
successShip.VelocityY,
successShip.DirectionX,
successShip.DirectionY);
var undock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Undock,
"pilot",
"undock-parity-smoke",
0,
successRun.CurrentEntityKey);
var undockResult = AetheriaRuntimeDaemonOperations.Execute(successRun, [undock], context);
RequireEqual(1, undockResult.AppliedCommandIds.Count,
"AetherDrive must satisfy the fossil propulsion alternative for rare compatible ships");
RequireEqual(poseBefore, (
successShip.PositionX,
successShip.PositionZ,
successShip.VelocityX,
successShip.VelocityY,
successShip.DirectionX,
successShip.DirectionY),
"undocking must preserve the ship pose, velocity, and direction instead of applying an invented launch");
Require(!successRun.Zones[0].Entities[1].DockingBayAssignments.Contains(0),
"successful undocking must release the exact occupied bay");
}
private static void VolumeSurfaceKeepsNativeShaderAbiInAssetVariant()
{
var player = Entity(0, 0, "player");
@ -2998,6 +3180,12 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
var home = Entity(0, 60, "workers");
home.EntityId = "station.home";
home.Kind = "station";
home.DockingBays = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "station-docking-bay" }
}];
home.DockingBayAssignments = [-1];
home.DockingBayContents = [Cargo()];
var catalog = EquipThrusterBank([worker]);
var run = new AetheriaRuntimeRunCheckpointCommit
{
@ -3013,6 +3201,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
var travelCount = 0;
var sawDock = false;
var rejectedHomeCommands = new List<string>();
var minimumHomeDistance = double.PositiveInfinity;
var maximumHomeSpeed = 0.0;
var physics = NewPhysics();
for (var frame = 0; frame < 500; frame++)
{
@ -3032,6 +3222,18 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
travelCount += tick.OperationResult.AppliedCommandIds.Count(id => id.EndsWith(":home-travel", StringComparison.Ordinal));
sawDock |= tick.OperationResult.AppliedCommandIds.Any(id => id.EndsWith(":home-dock", StringComparison.Ordinal));
rejectedHomeCommands.AddRange(tick.OperationResult.RejectedCommandIds.Where(id => id.Contains(":home-", StringComparison.Ordinal)));
var currentHomeZone = run.Zones.Single(zone => zone.ZoneIndex == 2);
var currentWorker = currentHomeZone.Entities.FirstOrDefault(entity => entity.EntityId == "worker.return-home");
var currentHome = currentHomeZone.Entities.FirstOrDefault(entity => entity.EntityId == "station.home");
if (currentWorker != null && currentHome != null)
{
minimumHomeDistance = Math.Min(minimumHomeDistance, Math.Sqrt(
Math.Pow(currentWorker.PositionX - currentHome.PositionX, 2) +
Math.Pow(currentWorker.PositionZ - currentHome.PositionZ, 2)));
maximumHomeSpeed = Math.Max(maximumHomeSpeed, Math.Sqrt(
currentWorker.VelocityX * currentWorker.VelocityX +
currentWorker.VelocityY * currentWorker.VelocityY));
}
if (sawDock)
break;
}
@ -3042,7 +3244,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
Require(sawApproach, "idle worker must approach its route and home through shared movement commands");
RequireEqual(2, travelCount, "idle worker must traverse the shortest route to its canonical home");
Require(sawDock,
$"idle worker must dock through the daemon docking command; worker={arrivedWorker.PositionX:0.###},{arrivedWorker.PositionZ:0.###} home={arrivedHome.PositionX:0.###},{arrivedHome.PositionZ:0.###} rejected={string.Join(",", rejectedHomeCommands)}");
$"idle worker must dock through the daemon docking command; worker={arrivedWorker.PositionX:0.###},{arrivedWorker.PositionZ:0.###} home={arrivedHome.PositionX:0.###},{arrivedHome.PositionZ:0.###} minDistance={minimumHomeDistance:0.###} maxSpeed={maximumHomeSpeed:0.###} rejected={string.Join(",", rejectedHomeCommands)}");
Require(arrivedHome.DockingBayAssignments.Contains(arrivedWorker.EntityIndex),
"home docking parentage must be the authoritative completion fact");

View file

@ -540,7 +540,12 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
Restitution: 0.2f,
Direction: new Vec2((float)direction.X, (float)direction.Y),
CollisionCategoryBits: isShip ? ShipCollisionCategory : WorldEntityCollisionCategory,
CollisionMaskBits: isShip ? ulong.MaxValue : ulong.MaxValue & ~PickupCollisionCategory);
CollisionMaskBits: isShip ? ulong.MaxValue : ulong.MaxValue & ~PickupCollisionCategory,
// The fossil moves entities directly and has no rigidbody collision response
// between ships/stations. Keep their Ymir bodies for fields and queries, but
// do not let invented circle radii hold a ship outside the 25-unit dock rule.
// Pickups retain group zero, so ship/pickup Begin contacts still own collection.
CollisionGroupIndex: -1);
}).Concat(pickups.Select(pickup => new PhysicsBody(
PickupPrefix + pickup.PickupIndex,
new Vec2((float)pickup.PositionX, (float)pickup.PositionZ),

View file

@ -356,7 +356,8 @@ static AetheriaPreparedPublication PreparePublication(
var operation = new AetheriaRuntimeDaemonOperationResult(
frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(),
tick.OperationResult.AppliedCommandIds.ToArray(),
tick.OperationResult.RejectedCommandIds.ToArray());
tick.OperationResult.RejectedCommandIds.ToArray(),
rejectedCommandReasons: tick.OperationResult.RejectedCommandReasons);
var publication = AetheriaRuntimeDaemonTickRunner.BuildPublications(
statePath,
operation,
@ -495,22 +496,9 @@ static async Task PublishCommittedFactAsync(
AetheriaRuntimeCommittedCommandFactDocument fact)
{
await node.PutCommittedCommandFactAsync(fact).ConfigureAwait(false);
var applied = string.Equals(
fact.Outcome,
AetheriaRuntimeCommandFactOutcomes.Applied,
StringComparison.Ordinal);
var receipt = new EveCommandReceiptDocument(
fact.FactId,
fact.CommandId,
fact.CommandKind.ToString(),
applied ? "reconciled" : "denied",
"Aetheria",
fact.SourceDaemonId,
"aetheria",
AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId,
applied ? "Command applied by authoritative daemon." : "Command rejected by authoritative daemon.",
fact.CommittedAtUtc,
Math.Max(fact.SourceFrameId, 0));
var receipt = AetheriaRuntimeDaemonReceiptProjector.Project(
fact,
AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId);
await node.Database.PutAsync(AetheriaRuntimeVerseRecordKeys.EveReceiptForCommand(receipt.CommandId), receipt)
.ConfigureAwait(false);
if (string.Equals(Environment.GetEnvironmentVariable("AETHERIA_TRACE_EVE_SNAPSHOTS"), "1", StringComparison.Ordinal))

View file

@ -16268,11 +16268,12 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
"AetheriaRuntimeDaemonCommandKinds.Interact",
"internal AetheriaRuntimeDaemonCommandEnvelope DockNearest(",
"internal AetheriaRuntimeDaemonCommandEnvelope Interact(",
"ApplyDockNearestIntent(run, command, context.Intents, context.DockingDistance)",
"ApplyDockNearestIntent(run, command, context, context.DockingDistance)",
"context.WormholeExitRadius",
"AetheriaRuntimeDaemonOperationContext.DefaultDockingDistance",
"AetheriaRuntimeDaemonOperationContext.DefaultWormholeExitRadius",
"ResolveInteractionDistance(command.ScalarValue, defaultDockingDistance)",
"var maximumDistance = defaultDockingDistance;",
"TryFindFirstDockTarget(",
"TryFindNearestWormholeTarget("
};
var daemonDockNearestSources = daemonDocuments + "\n" + daemonOperationClient + "\n" + daemonOperationsSource;
@ -16282,7 +16283,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
if (missingDaemonDockNearestSymbols.Length > 0)
{
throw new InvalidOperationException(
"Daemon no longer owns nearest docking target selection: " +
"Daemon no longer owns first-eligible docking target selection: " +
string.Join(", ", missingDaemonDockNearestSymbols));
}

View file

@ -4832,8 +4832,17 @@ public class DaemonRuntimeDocumentTests
public void DaemonOperationsInteractPrioritizesUndockWormholeThenDock()
{
var undockRun = RunWithTwoEntities();
EnsureRealDockingBay(undockRun.Zones[0].Entities[1]);
undockRun.Zones[0].Entities[1].ChildEntityIndices = new[] { 0 };
undockRun.Zones[0].Entities[1].DockingBayAssignments = new[] { 0, -1 };
undockRun.Zones[0].Entities[1].DockingBayAssignments = new[] { 0 };
var undockedActor = undockRun.Zones[0].Entities[0];
undockedActor.PositionX = 12;
undockedActor.PositionZ = -7;
undockedActor.VelocityX = 3;
undockedActor.VelocityY = -4;
undockedActor.DirectionX = 0.25;
undockedActor.DirectionY = 0.75;
var undockContext = InstallUndockPrerequisites(undockedActor);
var undock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Interact,
"codex",
@ -4843,19 +4852,17 @@ public class DaemonRuntimeDocumentTests
undock.ScalarValue = 10;
undock.PositionX = 10;
var undockResult = AetheriaRuntimeDaemonOperations.Execute(undockRun, new[] { undock });
var undockResult = AetheriaRuntimeDaemonOperations.Execute(undockRun, new[] { undock }, undockContext);
Assert.AreEqual(1, undockResult.AppliedCommandIds.Count);
Assert.AreEqual(1, undockResult.Intents.Docking.Count);
Assert.IsTrue(undockResult.Intents.Docking[0].Undock);
CollectionAssert.DoesNotContain(undockRun.Zones[0].Entities[1].DockingBayAssignments, 0);
var undockedActor = undockRun.Zones[0].Entities[0];
var dockParent = undockRun.Zones[0].Entities[1];
Assert.That(
Math.Sqrt(Math.Pow(undockedActor.PositionX - dockParent.PositionX, 2) +
Math.Pow(undockedActor.PositionZ - dockParent.PositionZ, 2)),
Is.EqualTo(72).Within(0.001));
Assert.AreEqual(0, undockedActor.VelocityX);
Assert.AreEqual(0, undockedActor.VelocityY);
Assert.AreEqual(12, undockedActor.PositionX);
Assert.AreEqual(-7, undockedActor.PositionZ);
Assert.AreEqual(3, undockedActor.VelocityX);
Assert.AreEqual(-4, undockedActor.VelocityY);
Assert.AreEqual(0.25, undockedActor.DirectionX);
Assert.AreEqual(0.75, undockedActor.DirectionY);
var wormholeRun = RunWithTwoEntities();
wormholeRun.Zones[0].GravityTerrainRadius = 10;
@ -5589,6 +5596,8 @@ public class DaemonRuntimeDocumentTests
public void DaemonOperationsRecordsNavigationIntentsForDaemonLoop()
{
var run = RunWithTwoEntities();
EnsureRealDockingBay(run.Zones[0].Entities[1]);
var undockContext = InstallUndockPrerequisites(run.Zones[0].Entities[0]);
var dock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Dock,
"codex",
@ -5614,7 +5623,7 @@ public class DaemonRuntimeDocumentTests
"session-navigation",
40,
"zone.0.entity.0");
var undockResult = AetheriaRuntimeDaemonOperations.Execute(run, new[] { undock });
var undockResult = AetheriaRuntimeDaemonOperations.Execute(run, new[] { undock }, undockContext);
Assert.AreEqual(1, undockResult.AppliedCommandIds.Count);
Assert.AreEqual(1, undockResult.Intents.Docking.Count);
@ -5624,14 +5633,15 @@ public class DaemonRuntimeDocumentTests
}
[Test]
public void DaemonOperationsSelectsNearestDockTargetFromAuthoritativeSnapshot()
public void DaemonOperationsSelectsFirstEligibleDockTargetFromAuthoritativeSnapshot()
{
var run = RunWithTwoEntities();
var zone = run.Zones[0];
zone.Entities[0].PositionX = 0;
zone.Entities[0].PositionY = 0;
zone.Entities[1].PositionX = 3;
zone.Entities[1].PositionY = 4;
zone.Entities[1].PositionX = 8;
zone.Entities[1].PositionZ = 0;
EnsureRealDockingBay(zone.Entities[1]);
zone.Entities = zone.Entities
.Concat(new[]
{
@ -5639,11 +5649,12 @@ public class DaemonRuntimeDocumentTests
{
EntityIndex = 2,
Name = "Far Dock",
PositionX = 8,
PositionY = 0
PositionX = 3,
PositionZ = 4
}
})
.ToArray();
EnsureRealDockingBay(zone.Entities[2]);
var dock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.DockNearest,
@ -5686,6 +5697,7 @@ public class DaemonRuntimeDocumentTests
public void DaemonOperationsRejectsDockWhenEntityIsAlreadyDocked()
{
var run = RunWithTwoEntities();
EnsureRealDockingBay(run.Zones[0].Entities[1]);
var dock = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.Dock,
"codex",
@ -5760,6 +5772,62 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual("Raven", restored.PlayerSettings.PlayerName);
}
private static void EnsureRealDockingBay(AetheriaRuntimeEntitySnapshotCommit target)
{
target.DockingBays = new[]
{
new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{
ItemKey = "test-docking-bay",
Enabled = true
}
}
};
target.DockingBayAssignments = new[] { -1 };
target.DockingBayContents = new[] { new AetheriaRuntimeCargoBayLoadoutCommit() };
}
private static AetheriaRuntimeDaemonOperationContext InstallUndockPrerequisites(
AetheriaRuntimeEntitySnapshotCommit actor)
{
actor.Equipment = (actor.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
.Concat(new[]
{
EquippedItem("test-dock-cockpit"),
EquippedItem("test-dock-thruster"),
EquippedItem("test-dock-reactor")
})
.ToArray();
return new AetheriaRuntimeDaemonOperationContext
{
Catalog = new AetheriaRuntimeCatalogSnapshot(
new[]
{
CatalogItem("test-dock-cockpit", new[] { BehaviorPayload("Cockpit") }),
CatalogItem("test-dock-thruster", new[] { BehaviorPayload("Thruster") }),
CatalogItem("test-dock-reactor", new[] { BehaviorPayload("Reactor") })
},
Array.Empty<AetheriaRuntimeCorporation>(),
Array.Empty<AetheriaRuntimeNameFile>())
};
}
private static AetheriaRuntimeLoadoutItemSlotCommit EquippedItem(string itemKey)
{
return new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit
{
ItemKey = itemKey,
Enabled = true,
Durability = 1,
Quantity = 1
}
};
}
private static AetheriaRuntimeRunCheckpointCommit RunWithTwoEntities()
{
return new AetheriaRuntimeRunCheckpointCommit

View file

@ -699,8 +699,9 @@ namespace GameCult.Aetheria.State.Verse
continue;
var homeDx = home.Entity.PositionX - worker.Entity.PositionX;
var homeDz = home.Entity.PositionZ - worker.Entity.PositionZ;
var dockingContactDistance = InteractionRadius(home.Entity) + InteractionRadius(worker.Entity);
if (Math.Sqrt(homeDx * homeDx + homeDz * homeDz) > dockingContactDistance + 0.5)
var dockingCommandDistance =
AetheriaRuntimeDaemonOperationContext.DefaultDockingDistance;
if (Math.Sqrt(homeDx * homeDx + homeDz * homeDz) > dockingCommandDistance)
commands.Add(IdleMovement(worker.Zone.ZoneIndex, worker.Entity, frameId, homeDx, homeDz, "home-approach"));
else
commands.Add(IdleCommand(worker.Zone.ZoneIndex, worker.Entity, frameId,
@ -725,7 +726,22 @@ namespace GameCult.Aetheria.State.Verse
var length = Math.Sqrt(dx * dx + dz * dz);
return IdleCommand(zoneIndex, entity, frameId, AetheriaRuntimeDaemonCommandKinds.SetMoveVector, phase, command =>
{
SetLocalHelmAxes(command, entity, dx, dz, length <= 0.0001 ? 0 : 1);
// Fossil MoveToState asks Agent.Accelerate for a target velocity; it does not
// blindly thrust toward the target position. Preserve that delta-v owner so
// an agent can brake through a close interaction radius instead of orbiting it.
const double defaultAgentTopSpeed = 100;
var desiredVelocityX = length <= 0.0001 ? 0 : dx / length * defaultAgentTopSpeed;
var desiredVelocityZ = length <= 0.0001 ? 0 : dz / length * defaultAgentTopSpeed;
var deltaVelocityX = desiredVelocityX - entity.VelocityX;
var deltaVelocityZ = desiredVelocityZ - entity.VelocityY;
var deltaVelocityLength = Math.Sqrt(
deltaVelocityX * deltaVelocityX + deltaVelocityZ * deltaVelocityZ);
SetLocalHelmAxes(
command,
entity,
deltaVelocityX,
deltaVelocityZ,
deltaVelocityLength <= 1 ? 0 : 1);
});
}

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using GameCult.Caching;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using MessagePack;
@ -542,6 +543,10 @@ namespace GameCult.Aetheria.State.Verse
public AetheriaRuntimeDaemonSimulationSettings SimulationSettings { get; set; } =
AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault;
[Key(23)]
public IReadOnlyDictionary<string, string> RejectedCommandReasons { get; set; } =
new Dictionary<string, string>();
public static AetheriaRuntimeDaemonFrameDocument Create(
AetheriaRuntimeRunCheckpointCommit run,
string daemonId,
@ -742,6 +747,9 @@ namespace GameCult.Aetheria.State.Verse
[Key(13)]
public AetheriaRuntimeDaemonCommandDocument Command { get; set; } = new AetheriaRuntimeDaemonCommandDocument();
[Key(14)]
public string RejectionReason { get; set; } = "";
public static AetheriaRuntimeCommittedCommandFactDocument FromAppliedCommand(
AetheriaRuntimeDaemonFrameDocument frame,
AetheriaRuntimeDaemonCommandDocument command,
@ -795,6 +803,11 @@ namespace GameCult.Aetheria.State.Verse
ClaimKind = claimKind,
CommandKind = command.Kind,
Outcome = string.IsNullOrWhiteSpace(outcome) ? AetheriaRuntimeCommandFactOutcomes.Applied : outcome,
RejectionReason = string.Equals(outcome, AetheriaRuntimeCommandFactOutcomes.Rejected, StringComparison.Ordinal) &&
(frame.RejectedCommandReasons ?? new Dictionary<string, string>())
.TryGetValue(command.CommandId ?? "", out var rejectionReason)
? rejectionReason ?? ""
: "",
CommittedAtUtc = DateTime.UtcNow.ToString("O"),
Command = command
};
@ -892,6 +905,37 @@ namespace GameCult.Aetheria.State.Verse
}
public static class AetheriaRuntimeDaemonReceiptProjector
{
public static EveCommandReceiptDocument Project(
AetheriaRuntimeCommittedCommandFactDocument fact,
string surfaceId)
{
fact ??= new AetheriaRuntimeCommittedCommandFactDocument();
var applied = string.Equals(
fact.Outcome,
AetheriaRuntimeCommandFactOutcomes.Applied,
StringComparison.Ordinal);
var message = applied
? "Command applied by authoritative daemon."
: string.IsNullOrWhiteSpace(fact.RejectionReason)
? "Command rejected by authoritative daemon."
: $"Command rejected by authoritative daemon: {fact.RejectionReason}.";
return new EveCommandReceiptDocument(
fact.FactId,
fact.CommandId,
fact.CommandKind.ToString(),
applied ? "reconciled" : "denied",
"Aetheria",
fact.SourceDaemonId,
"aetheria",
surfaceId ?? "",
message,
fact.CommittedAtUtc,
Math.Max(fact.SourceFrameId, 0));
}
}
[MessagePackObject]
public sealed class AetheriaRuntimeLootPickupCommand
{

View file

@ -12,18 +12,21 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeRunCheckpointCommit run,
IReadOnlyList<string> appliedCommandIds,
IReadOnlyList<string> rejectedCommandIds,
AetheriaRuntimeDaemonIntentState? intents = null)
AetheriaRuntimeDaemonIntentState? intents = null,
IReadOnlyDictionary<string, string>? rejectedCommandReasons = null)
{
Run = run ?? new AetheriaRuntimeRunCheckpointCommit();
AppliedCommandIds = appliedCommandIds ?? Array.Empty<string>();
RejectedCommandIds = rejectedCommandIds ?? Array.Empty<string>();
Intents = intents ?? new AetheriaRuntimeDaemonIntentState();
RejectedCommandReasons = rejectedCommandReasons ?? new Dictionary<string, string>();
}
public AetheriaRuntimeRunCheckpointCommit Run { get; }
public IReadOnlyList<string> AppliedCommandIds { get; }
public IReadOnlyList<string> RejectedCommandIds { get; }
public AetheriaRuntimeDaemonIntentState Intents { get; }
public IReadOnlyDictionary<string, string> RejectedCommandReasons { get; }
}
public sealed class AetheriaRuntimeDaemonOperationContext
@ -42,6 +45,32 @@ namespace GameCult.Aetheria.State.Verse
public double WormholeDistanceRatio { get; set; } =
AetheriaRuntimeDaemonRenderSettings.AetheriaDefault.WormholeDistanceRatio;
public AetheriaRuntimeCatalogSnapshot? Catalog { get; set; }
internal string RejectionReason { get; private set; } = "";
internal void ResetRejectionReason() => RejectionReason = "";
internal bool Reject(string reason)
{
RejectionReason = reason ?? "";
return false;
}
}
public static class AetheriaRuntimeDaemonRejectionReasons
{
public const string InvalidCommandState = "invalid-command-state";
public const string RunTerminal = "run-terminal";
public const string AuthorityDenied = "authority-denied";
public const string InvalidDockActor = "invalid-dock-actor";
public const string InvalidDockTarget = "invalid-dock-target";
public const string AlreadyDocked = "already-docked";
public const string NoEligibleDockingBay = "no-eligible-docking-bay";
public const string NotDocked = "not-docked";
public const string MissingCockpit = "missing-cockpit";
public const string MissingPropulsion = "missing-propulsion";
public const string MissingReactor = "missing-reactor";
public const string DockingBayCargoNotEmpty = "docking-bay-cargo-not-empty";
}
public static class AetheriaRuntimeDaemonOperations
@ -63,6 +92,7 @@ namespace GameCult.Aetheria.State.Verse
context.Intents = new AetheriaRuntimeDaemonIntentState();
var applied = new List<string>();
var rejected = new List<string>();
var rejectedReasons = new Dictionary<string, string>(StringComparer.Ordinal);
foreach (var command in commands ?? Enumerable.Empty<AetheriaRuntimeDaemonCommandDocument>())
{
@ -72,16 +102,24 @@ namespace GameCult.Aetheria.State.Verse
if (!AetheriaRuntimeRunLifecycle.IsActive(run))
{
rejected.Add(command.CommandId);
rejectedReasons[command.CommandId] = AetheriaRuntimeDaemonRejectionReasons.RunTerminal;
continue;
}
context.ResetRejectionReason();
if (ApplyOne(run, command, context))
applied.Add(command.CommandId);
else
{
rejected.Add(command.CommandId);
rejectedReasons[command.CommandId] = string.IsNullOrWhiteSpace(context.RejectionReason)
? AetheriaRuntimeDaemonRejectionReasons.InvalidCommandState
: context.RejectionReason;
}
}
return new AetheriaRuntimeDaemonOperationResult(run, applied, rejected, context.Intents);
return new AetheriaRuntimeDaemonOperationResult(
run, applied, rejected, context.Intents, rejectedReasons);
}
private static bool ApplyOne(
@ -166,16 +204,16 @@ namespace GameCult.Aetheria.State.Verse
case AetheriaRuntimeDaemonCommandKinds.SensorPing:
return ApplySensorPing(run, command, context.Intents);
case AetheriaRuntimeDaemonCommandKinds.Dock:
return ApplyDockIntent(run, command, context.Intents);
return ApplyDockIntent(run, command, context, context.DockingDistance);
case AetheriaRuntimeDaemonCommandKinds.DockNearest:
return ApplyDockNearestIntent(run, command, context.Intents, context.DockingDistance);
return ApplyDockNearestIntent(run, command, context, context.DockingDistance);
case AetheriaRuntimeDaemonCommandKinds.Undock:
return ApplyUndockIntent(run, command, context.Intents);
return ApplyUndockIntent(run, command, context);
case AetheriaRuntimeDaemonCommandKinds.Interact:
return ApplyInteractIntent(
run,
command,
context.Intents,
context,
context.DockingDistance,
context.WormholeExitRadius,
context.WormholeDistanceRatio);
@ -1039,8 +1077,17 @@ namespace GameCult.Aetheria.State.Verse
(parent.DockingBayAssignments ?? Array.Empty<int>()).Contains(entityIndex);
}
private static bool HasAvailableDockingBay(AetheriaRuntimeEntitySnapshotCommit parent) =>
(parent.DockingBayAssignments ?? Array.Empty<int>()).Any(index => index < 0);
private static bool HasAvailableDockingBay(AetheriaRuntimeEntitySnapshotCommit parent)
{
var bays = parent.DockingBays ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
var assignments = parent.DockingBayAssignments ?? Array.Empty<int>();
for (var index = 0; index < bays.Count; index++)
{
if (index >= assignments.Count || assignments[index] < 0)
return true;
}
return false;
}
private static bool TryFindCargoItem(
AetheriaRuntimeCargoBayLoadoutCommit cargo,
@ -1347,16 +1394,19 @@ namespace GameCult.Aetheria.State.Verse
private static bool ApplyDockIntent(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeDaemonCommandDocument command,
AetheriaRuntimeDaemonIntentState intents)
AetheriaRuntimeDaemonOperationContext context,
double maximumDistance)
{
var actor = ResolveActorEntityKey(run, command);
if (string.IsNullOrWhiteSpace(actor) || string.IsNullOrWhiteSpace(command.TargetEntityKey))
if (string.IsNullOrWhiteSpace(actor))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
if (string.IsNullOrWhiteSpace(command.TargetEntityKey))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockTarget);
if (!ApplyDockState(run, actor, command.TargetEntityKey, maximumDistance, context))
return false;
if (!ApplyDockState(run, actor, command.TargetEntityKey))
return false;
intents.Docking.Add(new AetheriaRuntimeDaemonDockingIntent
context.Intents.Docking.Add(new AetheriaRuntimeDaemonDockingIntent
{
ActorEntityKey = actor,
TargetEntityKey = command.TargetEntityKey ?? "",
@ -1368,37 +1418,40 @@ namespace GameCult.Aetheria.State.Verse
private static bool ApplyDockNearestIntent(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeDaemonCommandDocument command,
AetheriaRuntimeDaemonIntentState intents,
AetheriaRuntimeDaemonOperationContext context,
double defaultDockingDistance)
{
var actorKey = ResolveActorEntityKey(run, command);
if (string.IsNullOrWhiteSpace(actorKey) ||
!TryFindNearestDockTarget(
!TryResolveEntity(run, actorKey, out _, out _, out _))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
// DockingDistance is daemon-owned gameplay state. A client-provided scalar must
// not widen or narrow the fossil's interaction rule.
var maximumDistance = defaultDockingDistance;
if (!TryFindFirstDockTarget(
run,
actorKey,
ResolveInteractionDistance(command.ScalarValue, defaultDockingDistance),
maximumDistance,
out var targetKey))
{
return false;
}
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.NoEligibleDockingBay);
command.TargetEntityKey = targetKey;
return ApplyDockIntent(run, command, intents);
return ApplyDockIntent(run, command, context, maximumDistance);
}
private static bool ApplyUndockIntent(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeDaemonCommandDocument command,
AetheriaRuntimeDaemonIntentState intents)
AetheriaRuntimeDaemonOperationContext context)
{
var actor = ResolveActorEntityKey(run, command);
if (string.IsNullOrWhiteSpace(actor))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
if (!ApplyUndockState(run, actor, context))
return false;
if (!ApplyUndockState(run, actor))
return false;
intents.Docking.Add(new AetheriaRuntimeDaemonDockingIntent
context.Intents.Docking.Add(new AetheriaRuntimeDaemonDockingIntent
{
ActorEntityKey = actor,
Undock = true
@ -1409,7 +1462,7 @@ namespace GameCult.Aetheria.State.Verse
private static bool ApplyInteractIntent(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeDaemonCommandDocument command,
AetheriaRuntimeDaemonIntentState intents,
AetheriaRuntimeDaemonOperationContext context,
double defaultDockingDistance,
double defaultWormholeExitRadius,
double wormholeDistanceRatio)
@ -1418,11 +1471,11 @@ namespace GameCult.Aetheria.State.Verse
if (string.IsNullOrWhiteSpace(actorKey) ||
!TryResolveEntity(run, actorKey, out var zoneIndex, out var actorIndex, out _))
{
return false;
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
}
if (IsChildReferencedInZone(run, zoneIndex, actorIndex))
return ApplyUndockIntent(run, command, intents);
return ApplyUndockIntent(run, command, context);
if (TryFindNearestWormholeTarget(
run,
@ -1434,11 +1487,11 @@ namespace GameCult.Aetheria.State.Verse
out _))
{
command.TargetZoneIndex = targetZoneIndex;
return ApplyEnterWormholeIntent(run, command, intents,
return ApplyEnterWormholeIntent(run, command, context.Intents,
defaultWormholeExitRadius, wormholeDistanceRatio);
}
return ApplyDockNearestIntent(run, command, intents, defaultDockingDistance);
return ApplyDockNearestIntent(run, command, context, defaultDockingDistance);
}
private static double ResolveInteractionDistance(double commandDistance, double defaultDistance)
@ -1451,7 +1504,7 @@ namespace GameCult.Aetheria.State.Verse
: double.PositiveInfinity;
}
private static bool TryFindNearestDockTarget(
private static bool TryFindFirstDockTarget(
AetheriaRuntimeRunCheckpointCommit run,
string actorEntityKey,
double maxDistance,
@ -1467,30 +1520,25 @@ namespace GameCult.Aetheria.State.Verse
return false;
var maxDistanceSq = maxDistance > 0.0 ? maxDistance * maxDistance : double.PositiveInfinity;
var closestDistanceSq = double.PositiveInfinity;
var closestIndex = -1;
var entities = zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>();
for (var index = 0; index < entities.Count; index++)
{
var candidate = entities[index];
if (candidate == null || index == actorIndex)
if (candidate == null || candidate.EntityIndex == actorIndex || !HasAvailableDockingBay(candidate))
continue;
var deltaX = candidate.PositionX - actor.PositionX;
var deltaY = candidate.PositionY - actor.PositionY;
var distanceSq = (deltaX * deltaX) + (deltaY * deltaY);
if (distanceSq >= maxDistanceSq || distanceSq >= closestDistanceSq)
var deltaZ = candidate.PositionZ - actor.PositionZ;
var distanceSq = (deltaX * deltaX) + (deltaZ * deltaZ);
if (distanceSq >= maxDistanceSq)
continue;
closestDistanceSq = distanceSq;
closestIndex = index;
targetEntityKey = AetheriaRuntimeRunCheckpointCommit.EntityRecordKey(
run.RunId, zoneIndex, candidate.EntityIndex);
return true;
}
if (closestIndex < 0)
return false;
targetEntityKey = AetheriaRuntimeRunCheckpointCommit.EntityRecordKey(run.RunId, zoneIndex, closestIndex);
return true;
return false;
}
private static bool TryFindNearestWormholeTarget(
@ -1540,73 +1588,110 @@ namespace GameCult.Aetheria.State.Verse
private static bool ApplyDockState(
AetheriaRuntimeRunCheckpointCommit run,
string actorEntityKey,
string targetEntityKey)
string targetEntityKey,
double maximumDistance,
AetheriaRuntimeDaemonOperationContext context)
{
if (!TryResolveEntity(run, actorEntityKey, out var actorZoneIndex, out var actorIndex, out _) ||
if (!TryResolveEntity(run, actorEntityKey, out var actorZoneIndex, out var actorIndex, out var actor))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
if (
!TryResolveEntity(run, targetEntityKey, out var targetZoneIndex, out var targetIndex, out var target))
{
return false;
}
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockTarget);
if (actorZoneIndex != targetZoneIndex || actorIndex == targetIndex)
return false;
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockTarget);
if (IsChildReferencedInZone(run, actorZoneIndex, actorIndex))
return false;
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.AlreadyDocked);
RemoveChildReferenceFromZone(run, actorZoneIndex, actorIndex);
var deltaX = target.PositionX - actor.PositionX;
var deltaZ = target.PositionZ - actor.PositionZ;
var maximumDistanceSq = maximumDistance > 0
? maximumDistance * maximumDistance
: double.PositiveInfinity;
if ((deltaX * deltaX) + (deltaZ * deltaZ) >= maximumDistanceSq)
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockTarget);
var bays = target.DockingBays ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
var existingAssignments = target.DockingBayAssignments ?? Array.Empty<int>();
var bayIndex = -1;
for (var index = 0; index < bays.Count; index++)
{
if (index >= existingAssignments.Count || existingAssignments[index] < 0)
{
bayIndex = index;
break;
}
}
if (bayIndex < 0)
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.NoEligibleDockingBay);
var childIndices = (target.ChildEntityIndices ?? Array.Empty<int>()).ToList();
if (!childIndices.Contains(actorIndex))
childIndices.Add(actorIndex);
target.ChildEntityIndices = childIndices.ToArray();
var assignments = (target.DockingBayAssignments ?? Array.Empty<int>()).ToList();
var assigned = false;
for (var index = 0; index < assignments.Count; index++)
{
if (assignments[index] >= 0)
continue;
assignments[index] = actorIndex;
assigned = true;
break;
}
if (!assigned)
assignments.Add(actorIndex);
var assignments = Enumerable.Range(0, bays.Count)
.Select(index => index < existingAssignments.Count ? existingAssignments[index] : -1)
.ToArray();
assignments[bayIndex] = actorIndex;
target.DockingBayAssignments = assignments.ToArray();
return true;
}
private static bool ApplyUndockState(
AetheriaRuntimeRunCheckpointCommit run,
string actorEntityKey)
string actorEntityKey,
AetheriaRuntimeDaemonOperationContext context)
{
if (!TryResolveEntity(run, actorEntityKey, out var zoneIndex, out var actorIndex, out var actor))
return false;
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidDockActor);
var zone = (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
.FirstOrDefault(candidate => candidate != null && candidate.ZoneIndex == zoneIndex);
var parent = (zone?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.FirstOrDefault(entity => entity != null &&
((entity.ChildEntityIndices ?? Array.Empty<int>()).Contains(actorIndex) ||
(entity.DockingBayAssignments ?? Array.Empty<int>()).Contains(actorIndex)));
if (parent == null || !RemoveChildReferenceFromZone(run, zoneIndex, actorIndex))
return false;
if (parent == null)
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.NotDocked);
var directionLength = Math.Sqrt(
parent.DirectionX * parent.DirectionX + parent.DirectionY * parent.DirectionY);
var directionX = directionLength < 0.001 ? 0 : parent.DirectionX / directionLength;
var directionZ = directionLength < 0.001 ? 1 : parent.DirectionY / directionLength;
actor.PositionX = parent.PositionX + directionX * 72;
actor.PositionZ = parent.PositionZ + directionZ * 72;
actor.VelocityX = 0;
actor.VelocityY = 0;
actor.DirectionX = directionX;
actor.DirectionY = directionZ;
var assignments = parent.DockingBayAssignments ?? Array.Empty<int>();
var dockingBayIndex = -1;
for (var index = 0; index < assignments.Count; index++)
{
if (assignments[index] == actorIndex)
{
dockingBayIndex = index;
break;
}
}
if (dockingBayIndex < 0)
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.NotDocked);
if (!HasInstalledBehavior(actor, context.Catalog, "Cockpit"))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.MissingCockpit);
if (!HasInstalledBehavior(actor, context.Catalog, "Thruster") &&
!HasInstalledBehavior(actor, context.Catalog, "AetherDrive"))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.MissingPropulsion);
if (!HasInstalledBehavior(actor, context.Catalog, "Reactor"))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.MissingReactor);
var dockingBayContents = parent.DockingBayContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>();
if (dockingBayIndex < dockingBayContents.Count &&
(dockingBayContents[dockingBayIndex]?.Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
.Any(slot => slot?.Item != null))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.DockingBayCargoNotEmpty);
if (!RemoveChildReferenceFromZone(run, zoneIndex, actorIndex))
return context.Reject(AetheriaRuntimeDaemonRejectionReasons.NotDocked);
return true;
}
private static bool HasInstalledBehavior(
AetheriaRuntimeEntitySnapshotCommit actor,
AetheriaRuntimeCatalogSnapshot? catalog,
string behaviorKind) =>
AetheriaRuntimeEquippedBehaviorQueries.Find(actor, catalog, behaviorKind).Count > 0;
private static bool IsChildReferencedInZone(
AetheriaRuntimeRunCheckpointCommit run,
int zoneIndex,

View file

@ -149,7 +149,13 @@ namespace GameCult.Aetheria.State.Verse
.Concat(operationResult.RejectedCommandIds)
.Distinct(StringComparer.Ordinal)
.ToArray(),
operationResult.Intents);
operationResult.Intents,
MergeRejectedReasons(
operationResult.RejectedCommandReasons,
preRejectedCommandIds.ToDictionary(
commandId => commandId,
_ => AetheriaRuntimeDaemonRejectionReasons.AuthorityDenied,
StringComparer.Ordinal)));
}
var simulationStepCount = options.AdvanceSimulation && AetheriaRuntimeRunLifecycle.IsActive(operationResult.Run)
? Math.Max(1, options.SimulationStepCount)
@ -180,7 +186,10 @@ namespace GameCult.Aetheria.State.Verse
agentResult.Run,
operationResult.AppliedCommandIds.Concat(agentResult.AppliedCommandIds).ToArray(),
operationResult.RejectedCommandIds.Concat(agentResult.RejectedCommandIds).ToArray(),
MergeIntents(operationResult.Intents, agentResult.Intents));
MergeIntents(operationResult.Intents, agentResult.Intents),
MergeRejectedReasons(
operationResult.RejectedCommandReasons,
agentResult.RejectedCommandReasons));
}
AetheriaRuntimeDaemonSimulation.Step(
operationResult.Run,
@ -208,6 +217,7 @@ namespace GameCult.Aetheria.State.Verse
Trace("frame-projection");
frame.AppliedCommandIds = operationResult.AppliedCommandIds;
frame.RejectedCommandIds = operationResult.RejectedCommandIds;
frame.RejectedCommandReasons = operationResult.RejectedCommandReasons;
frame.AccountedCommandIds = accountedBeforeTick
.Concat(operationResult.AppliedCommandIds)
.Concat(operationResult.RejectedCommandIds)
@ -347,6 +357,18 @@ namespace GameCult.Aetheria.State.Verse
return merged;
}
private static IReadOnlyDictionary<string, string> MergeRejectedReasons(
IReadOnlyDictionary<string, string>? first,
IReadOnlyDictionary<string, string>? second)
{
var merged = new Dictionary<string, string>(StringComparer.Ordinal);
foreach (var pair in first ?? new Dictionary<string, string>())
merged[pair.Key] = pair.Value ?? "";
foreach (var pair in second ?? new Dictionary<string, string>())
merged[pair.Key] = pair.Value ?? "";
return merged;
}
private static void EnsureEntityIds(AetheriaRuntimeRunCheckpointCommit run)
{
var used = new HashSet<string>(StringComparer.Ordinal);

View file

@ -2856,6 +2856,39 @@ Run-lifecycle ownership is deliberately narrower than a quest system:
simulation is frozen, and inspects the Eve surface state bindings. Completion
remains unimplemented until a source-backed game-mode rule owns it.
Docking ownership follows the fossil's entity and `ActionGameManager` path:
- Owner: daemon docking operations own bay selection, parentage, and the
dock/undock acceptance decision.
- Inputs: zone entity order, the 25-unit interaction radius, real docking-bay
slots and assignments, occupied-bay cargo, installed Cockpit,
Thruster-or-AetherDrive, and Reactor behaviors, and the ship's preserved
authoritative pose, velocity, and direction. Ymir retains entity bodies for
fields and spatial queries, but ship/station bodies share a non-colliding
group because the fossil had no rigidbody entity collision response; pickup
bodies remain independently collidable with ships.
- Outputs: exact parent/assignment mutation, docking intent, and an
authoritative rejection reason carried by the command fact and Eve receipt.
- Derived state: camera target, subject visibility, movement suppression, menu
copy, and effects derive from dock parentage plus the receipt. They do not
decide whether docking happened.
- Forbidden writers: Unity `TryDock`/`TryUndock`, camera transitions, client
proximity, command-supplied failure text, and renderer-local component checks
cannot mutate or explain docking truth.
- Shared paths: explicit Dock, DockNearest, contextual Interact, autonomous
homecoming, reconnect, and purchased docked ships use the same assignment
representation; explicit Undock and contextual Interact use the same
prerequisite transaction.
- Cut line: the daemon may not append a synthetic docking slot, select the
geometrically nearest ineligible entity, move a ship 72 units, zero its
velocity, overwrite its direction during undock, or let invented generic
circle radii make the authored center-distance rule unreachable.
- Verification layer: operation tests cover every ordered rejection, bay cargo,
first-eligible selection, preserved pose/velocity/direction, exact receipt
reason, entity pass-through during home approach, and retained ship/pickup
contact collection; the live witness remains responsible for camera/effect
timing.
Ymir restart ownership is deliberately private and asymmetric:
- Owner: `AetheriaYmirPersistenceCoordinator` owns reconstruction durability;

View file

@ -27,7 +27,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Weapons | ServerShared behaviors + Unity effects | daemon plus Ymir geometry/kinematics | action capability, weapon state, shot/damage receipts | effects/audio/HUD | instant and constant resource/timing lifecycles are daemon-owned; charged weapons accept one semantic request, spool without requiring a solution, hold at full charge, commit automatically when a solution appears, and perform deterministic once-per-second malfunction hazard checks after the authored safe hold interval with increasing persisted risk; generic Eve `weapon.state` exposes charge hold/risk and feedback exposes readiness, commit, refusal, and malfunction chronology; committed direct damage now enters the shared daemon armor-cell transaction | guided persistent payloads, visibility/wear, remaining impact-distribution parity, and Unity effect reconciliation |
| Destruction/drops | hull death, 25% equipment rolls, unconditional cargo drops, 25-unit launch, 30-second pickups | daemon | destruction identity, death/drop events, typed pickups | provider-advertised destruction effect and pickups | owner-exists; wired; exclusive; projected: direct and deployable lethal damage commit one deterministic destruction transaction, clear live references, retain only a non-rendered identity tombstone, and emit exact pickups/events; the reserved client `DestroyEntity` command is rejected; Aetheria advertises its original big explosion as `effect.feedback.entity.destroyed`, lowered generically by EveUnity | equipment-destruction-before-hull parity and multiplayer reconnect chronology |
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | pickup world entity plus beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; ship contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; Aetheria maps pickup collision only against ship bodies, so stations and other world bodies cannot become cargo writers; 30s daemon lifetime; instant cargo teleport deleted; current-zone pickups occupy ordinary rows in the shared Eve entity SoA body with stable logical identity and provider-owned assets; `pilot.scoop` advertises a generic `button-hold.v1` scalar contract, the released client sends `1` on press and `0` on release through `SetTractorPower`, both receipts reconcile, and daemon power returns exactly to zero; the provider build removes the fossil's embedded tractor object from ship prefabs, and `beam.presentation` attaches the sole standalone effect to the SoA ship; released warm witnesses prove successful exactly-once Ymir collection and controlled-player `cargo-capacity` rejection with unchanged cargo | polish provider beam shape/attachment |
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | live generic Unity witness now proves advertised dock/undock actions, daemon bay assignment, dock-parent inclusion in the SoA view, sharing of the dock parent's equipment-derived contact picture, generic camera retargeting, controlled-subject hiding, movement suppression, and restoration on undock; the starter station and local raider form a deterministic Terminus departure proof | restore fossil component-prerequisite rejection reasons, exact undock placement, wormhole priority, reconnect, and docked inventory/trade surfaces |
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon docking now preserves the fossil transaction: stable zone order selects the first entity with a real empty bay inside the fixed 25-unit XZ center radius; undock checks installed Cockpit, Thruster-or-AetherDrive, Reactor, then empty bay cargo in source order; rejection reasons survive committed command facts into generic Eve receipts; success removes parentage without moving, stopping, or rotating the ship. Ymir world entities retain gravity/query bodies but do not invent ship/station rigidbody collision response that would make the 25-unit rule unreachable; ship/pickup Begin contacts remain enabled. The live generic Unity witness also proves advertised actions, bay assignment, dock-parent SoA inclusion and sensor sharing, camera retargeting, controlled-subject hiding, movement suppression, and restoration on undock | reconnect, docked inventory/trade surfaces, and authored dock-camera blend/effect chronology |
| Wormhole travel | `ActionGameManager.EnterWormhole` plus `Ship` enter/exit state | daemon fixed-step transition plus Ymir exclusion | current-entity transition state and feedback chronology | provider-selected generic transition lowering | command acceptance no longer moves an entity immediately; player interact, explicit travel, and agent routing derive the same canonical adjacent-zone wormhole and proximity gate, then persist four-second `entering`, authoritative transfer, four-second `exiting`, and one-frame `completed` phases. The daemon owns smootherstep XZ motion, the fossil 1000-unit visual-depth lever, deterministic 20-unit exit direction, 50-unit exit radius, target-adjacency discovery, and exactly-once start/transfer/completion events. Flight and every world-physics implementation receive no transitioning body; Ymir resumes on the tick after completion. Smoke serializes and rehydrates mid-entry and proves agents traverse multi-edge routes through the same command boundary | generic provider transition effect/camera lowering and live multi-zone pilot witness |
| Inventory/equipment | inventory panels + ServerShared | daemon | inventory/equipment surfaces | generic UI | owner-exists; wired/projected in fragments; not proven | all transfer directions and rejection |
| Trade | trade UI/economy | daemon | stock, quote, purchase commands | generic UI | daemon derives station, stock row, catalog item, current price, quantity, credits, target capacity, and hull-vs-cargo result; Eve advertises only currently available stock actions; generic Unity live witness receives an authoritative purchase receipt while paused | sell flow, quote expiry, contested stock, and full trade surface parity |