Prove contact-gated cargo collection

This commit is contained in:
Meta Vens 2026-07-15 16:36:13 +01:00
commit 84429ad6eb
10 changed files with 124 additions and 20 deletions

View file

@ -46,6 +46,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
RunCheck(StableEntityIdentitySurvivesCrossZoneReindex);
RunCheck(TractorRampsAndPullsThroughYmirWithoutTeleportingCargo);
RunCheck(PickupIsCapacityCheckedExactlyOnceAndExpires);
RunCheck(StationBodiesCannotConsumePickups);
RunCheck(PickupShieldContactCollectsOrBounces);
RunCheck(YmirRestartDoesNotReplayConsumedPickupContact);
}
@ -164,6 +165,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
MissingWorldPhysicsOwnerCannotAdvanceShips,
TractorRampsAndPullsThroughYmirWithoutTeleportingCargo,
PickupIsCapacityCheckedExactlyOnceAndExpires,
StationBodiesCannotConsumePickups,
PickupShieldContactCollectsOrBounces,
YmirRestartDoesNotReplayConsumedPickupContact,
ThermalCellsUseFossilConductionAndRadiation,
@ -3061,8 +3063,22 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
RequireEqual(1, CargoQuantity(ship, salvage.ItemKey), "duplicate contact facts must commit cargo exactly once");
RequireEqual(1, run.GameEvents.Count(value => value.Kind == "pickup.collected" && value.PickupIndex == 7),
"duplicate contact facts must emit one collection event");
var collectionEvent = run.GameEvents.Single(value => value.Kind == "pickup.collected" && value.PickupIndex == 7);
RequireNear(1, collectionEvent.ScalarValue, 0.000001,
"collection feedback must publish the committed cargo delta");
RequireNear(0, collectionEvent.AuxiliaryValue, 0.000001,
"collection feedback must publish cargo quantity before the transaction");
RequireEqual(1, run.PickupContactReceipts.Count(value => value.FactId == contact.FactId),
"duplicate delivery of one Ymir fact must persist one Aetheria consumption receipt");
var collectionFeedback = AetheriaRuntimeDaemonGameSurfaceBuilder.Build(
new AetheriaRuntimeDaemonFrameDocument { FrameId = 3, Run = run },
new AetheriaRuntimeDaemonHealthDocument(),
AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon"));
Require(Flatten(collectionFeedback.Surface.Root).Any(node => node.Kind == "feedback.event" &&
node.Props["eventKind"] == "pickup.collected" && node.Props["pickupIndex"] == "7" &&
node.Props["itemKey"] == salvage.ItemKey && node.Props["scalarValue"] == "1" &&
node.Props["cargoQuantityBefore"] == "0" && node.Props["cargoQuantityAfter"] == "1"),
"Eve feedback must publish the exact cargo delta committed by one Ymir contact fact");
zone.DroppedPickups = [new AetheriaRuntimeDroppedPickupCommit { PickupIndex = 8, PositionX = 10, Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = salvage.ItemKey, Quantity = 1 }, LifetimeSeconds = 30 }];
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-expiry-smoke.cc"), run,
@ -3072,6 +3088,61 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
"daemon lifetime owner must emit authoritative pickup expiry event");
}
private static void StationBodiesCannotConsumePickups()
{
var hull = CatalogItem("station-filter-hull"); hull.HullCapacity = PerformanceStat(1);
var salvage = CatalogItem("station-filter-salvage"); salvage.Volume = 1;
var cargoBay = CatalogItem("station-filter-cargo-bay"); cargoBay.InteriorOccupiedCells = 1;
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage, cargoBay], [], []);
var station = Entity(0, 0, "player");
station.Kind = "station";
station.HullItemKey = hull.ItemKey;
station.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit
{
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 }
}];
station.CargoContents = [Cargo()];
var ship = Entity(1, 200, "player");
var run = new AetheriaRuntimeRunCheckpointCommit
{
CurrentZoneIndex = 0,
CurrentEntityKey = "zone.0.entity.1",
Zones = [new AetheriaRuntimeZoneSnapshotCommit
{
ZoneIndex = 0,
Entities = [station, ship],
DroppedPickups = [new AetheriaRuntimeDroppedPickupCommit
{
PickupIndex = 9,
PositionX = 0,
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = salvage.ItemKey, Quantity = 1 },
LifetimeSeconds = 30
}]
}]
};
using var physics = NewPhysics();
AetheriaRuntimeDaemonTickRunner.Tick(
Path.Combine(Path.GetTempPath(), "aetheria-pickup-station-filter.cc"),
run,
new AetheriaRuntimeDaemonTickOptions
{
WorldPhysics = physics,
FrameId = 1,
FixedDeltaSeconds = 0.1,
SimulationTimeSeconds = 0.1,
Catalog = catalog,
BuildPublications = false
});
RequireEqual(1, run.Zones[0].DroppedPickups.Count,
"station world bodies must not consume ship-scoop pickups");
RequireEqual(0, run.PickupContactReceipts.Count,
"Ymir collision filtering must not publish station/pickup Begin facts");
RequireEqual(0, CargoQuantity(station, salvage.ItemKey),
"station cargo must remain unchanged without a ship shield contact");
}
private static void PickupShieldContactCollectsOrBounces()
{
var hull = CatalogItem("contact-hull"); hull.HullCapacity = PerformanceStat(1);
@ -3104,6 +3175,11 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
Require(full.Zones[0].DroppedPickups[0].VelocityX > 20, "failed pickup must receive the fossil outward kick");
RequireEqual(1, full.GameEvents.Count(value => value.Kind == "pickup.rejected" && value.PickupIndex == 10),
"capacity rejection must emit one stable event");
var rejectionEvent = full.GameEvents.Single(value => value.Kind == "pickup.rejected" && value.PickupIndex == 10);
RequireEqual("cargo-capacity", rejectionEvent.Reason,
"capacity rejection feedback must name the provider-owned reason");
RequireNear(1, rejectionEvent.AuxiliaryValue, 0.000001,
"capacity rejection feedback must preserve the pre-contact cargo quantity");
RequireEqual(1, full.PickupContactReceipts.Count,
"capacity rejection must consume its Box3D Begin fact exactly once");
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-contact-full-second.cc"), full,
@ -3116,7 +3192,10 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
new AetheriaRuntimeDaemonFrameDocument { FrameId = 1, Run = full },
new AetheriaRuntimeDaemonHealthDocument(),
AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon"));
Require(Flatten(feedback.Surface.Root).Any(node => node.Kind == "feedback.event" && node.Props["eventKind"] == "pickup.rejected" && node.Props["pickupIndex"] == "10"),
Require(Flatten(feedback.Surface.Root).Any(node => node.Kind == "feedback.event" &&
node.Props["eventKind"] == "pickup.rejected" && node.Props["pickupIndex"] == "10" &&
node.Props["reason"] == "cargo-capacity" &&
node.Props["cargoQuantityBefore"] == "1" && node.Props["cargoQuantityAfter"] == "1"),
"Eve surface must project authoritative pickup feedback chronology");
}

View file

@ -8,6 +8,9 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
private const string EntityPrefix = "aetheria.daemon.entity.";
private const string PickupPrefix = "aetheria.daemon.pickup.";
private const string PhysicalPayloadPrefix = "aetheria.physical-payload.";
private const ulong WorldEntityCollisionCategory = 1UL;
private const ulong ShipCollisionCategory = 2UL;
private const ulong PickupCollisionCategory = 4UL;
private readonly Dictionary<WorldKey, SessionState> _sessions = new();
public string ImplementationId => "ymir.box3d.retained-session.v1";
@ -524,6 +527,7 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
throw new InvalidOperationException(
$"Entity index {entity.EntityIndex} has no stable runtime identity for retained Ymir ownership.");
var isStatic = string.Equals(entity.Kind, "station", StringComparison.OrdinalIgnoreCase);
var isShip = string.Equals(entity.Kind, "ship", StringComparison.OrdinalIgnoreCase);
var direction = Normalize(entity.DirectionX, entity.DirectionY, 0, 1);
return new PhysicsBody(
BodyId(entity),
@ -533,14 +537,18 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
1,
IsStatic: isStatic,
Restitution: 0.2f,
Direction: new Vec2((float)direction.X, (float)direction.Y));
Direction: new Vec2((float)direction.X, (float)direction.Y),
CollisionCategoryBits: isShip ? ShipCollisionCategory : WorldEntityCollisionCategory,
CollisionMaskBits: isShip ? ulong.MaxValue : ulong.MaxValue & ~PickupCollisionCategory);
}).Concat(pickups.Select(pickup => new PhysicsBody(
PickupPrefix + pickup.PickupIndex,
new Vec2((float)pickup.PositionX, (float)pickup.PositionZ),
new Vec2((float)pickup.VelocityX, (float)pickup.VelocityZ),
5,
1,
Restitution: 0.2f)))
Restitution: 0.2f,
CollisionCategoryBits: PickupCollisionCategory,
CollisionMaskBits: ShipCollisionCategory)))
.ToArray();
private static string BodyId(AetheriaRuntimeEntitySnapshotCommit entity) => EntityPrefix + entity.EntityId;

View file

@ -9,6 +9,6 @@
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13",
"org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1",
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.2",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.31"
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.32"
}
}

View file

@ -142,7 +142,7 @@
"hash": "140e1bd963a0033e66777a3b2c5fe6e9c97dfe32"
},
"org.gamecult.eve.unity-scene": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.31",
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.32",
"depth": 0,
"source": "git",
"dependencies": {
@ -152,7 +152,7 @@
"com.unity.mathematics": "1.3.2",
"com.unity.modules.particlesystem": "1.0.0"
},
"hash": "140e1bd963a0033e66777a3b2c5fe6e9c97dfe32"
"hash": "817912a041ac1911e1e27a4b88617754d90ad4b7"
},
"com.unity.modules.assetbundle": {
"version": "1.0.0",

View file

@ -7,6 +7,13 @@ namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeCargoCapacityQueries
{
public static int Quantity(AetheriaRuntimeEntitySnapshotCommit? entity) =>
(entity?.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>())
.Where(bay => bay != null)
.SelectMany(bay => bay.Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
.Where(slot => slot?.Item != null)
.Sum(slot => Math.Max(0, slot.Item.Quantity));
public static double Capacity(AetheriaRuntimeEntitySnapshotCommit? entity, AetheriaRuntimeCatalogSnapshot? catalog)
{
if (entity == null || catalog == null)

View file

@ -302,6 +302,8 @@ namespace GameCult.Aetheria.State.Verse
("pickupIndex", value.PickupIndex.ToString(CultureInfo.InvariantCulture)),
("itemKey", value.ItemKey), ("scalarValue", FormatNumber(value.ScalarValue)),
("auxiliaryValue", FormatNumber(value.AuxiliaryValue)),
("cargoQuantityBefore", PickupCargoQuantity(value, after: false)),
("cargoQuantityAfter", PickupCargoQuantity(value, after: true)),
("subjectKey", value.SubjectKey), ("reason", value.Reason),
("position", string.Join(",", new[] { FormatNumber(value.PositionX), FormatNumber(value.PositionZ) })),
("currentFrameId", frameId.ToString(CultureInfo.InvariantCulture))
@ -310,6 +312,18 @@ namespace GameCult.Aetheria.State.Verse
return Node("aetheria.daemon.game.feedback", "feedback.stream", new[] { ("retainedCount", events.Length.ToString(CultureInfo.InvariantCulture)) }, events);
}
private static string PickupCargoQuantity(AetheriaRuntimeGameEventCommit gameEvent, bool after)
{
if (!string.Equals(gameEvent.Kind, "pickup.collected", StringComparison.Ordinal) &&
!string.Equals(gameEvent.Kind, "pickup.rejected", StringComparison.Ordinal))
return "";
var before = Math.Max(0, gameEvent.AuxiliaryValue);
var current = string.Equals(gameEvent.Kind, "pickup.collected", StringComparison.Ordinal)
? before + Math.Max(0, gameEvent.ScalarValue)
: before;
return FormatNumber(after ? current : before);
}
private static AetheriaRuntimeSurfaceComponent ShotReceiptStream(AetheriaRuntimeRunCheckpointCommit run)
{
var receipts = (run.ShotReceipts ?? Array.Empty<AetheriaRuntimeShotReceiptCommit>())

View file

@ -203,6 +203,7 @@ namespace GameCult.Aetheria.State.Verse
.FirstOrDefault(value => value != null && value.PickupIndex == contact.PickupIndex);
var itemKey = pickup?.Item?.ItemKey ?? "";
var quantity = Math.Max(1, pickup?.Item?.Quantity ?? 1);
var cargoQuantityBefore = AetheriaRuntimeCargoCapacityQueries.Quantity(entity);
var result = entity == null
? AetheriaRuntimePickupContactResult.Ignored
: AetheriaRuntimePickupTransactions.ApplyContact(zone, entity, contact, catalog);
@ -240,7 +241,11 @@ namespace GameCult.Aetheria.State.Verse
TargetEntityIndex = entityIndex,
PickupIndex = contact.PickupIndex,
ItemKey = itemKey,
ScalarValue = quantity
ScalarValue = quantity,
AuxiliaryValue = cargoQuantityBefore,
Reason = result == AetheriaRuntimePickupContactResult.RejectedCapacity
? "cargo-capacity"
: ""
});
}
}

View file

@ -310,7 +310,7 @@ namespace GameCult.Aetheria.State.Verse
{
var entity = entities[index];
WriteInt32(bytes, layout.EntityIndex + index * IntStride, entity.EntityIndex);
WriteInt32(bytes, layout.CargoQuantity + index * IntStride, CountCargoUnits(entity));
WriteInt32(bytes, layout.CargoQuantity + index * IntStride, AetheriaRuntimeCargoCapacityQueries.Quantity(entity));
WriteFloat3(bytes, layout.Position, index, entity.PositionX, entity.PositionY, entity.PositionZ);
WriteFloat(bytes, layout.RotationRadians, index, Math.Atan2(entity.DirectionX, entity.DirectionY));
WriteFloat3(bytes, layout.Velocity, index, entity.VelocityX, 0.0, entity.VelocityY);
@ -423,15 +423,6 @@ namespace GameCult.Aetheria.State.Verse
return !double.IsNaN(value) && !double.IsInfinity(value);
}
private static int CountCargoUnits(AetheriaRuntimeEntitySnapshotCommit entity)
{
return (entity.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>())
.Where(bay => bay != null)
.SelectMany(bay => bay.Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
.Where(slot => slot?.Item != null)
.Sum(slot => Math.Max(0, slot.Item.Quantity));
}
private readonly struct EntityHotSlabLayout
{
private EntityHotSlabLayout(

View file

@ -26,7 +26,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Thermal/energy | cell conduction, capacitor/reactor/radiator network, and cockpit thermal exposure | daemon | ship/equipment power, temperature, medical state, risk and death feedback | schematic/post effects | owner-exists; wired; exclusive; projected; generic timing and native asset delivery lowered: catalog hull and installed-item shapes derive cell mass/conductivity/topology; local temperature derives thermal performance, wear potential and online state; all consumers share capacitor-first/reactor-residual transactions; powered radiators pump before reactor settlement; reactor heat then enters the same cell network before conduction/radiation; cockpit-cell temperature drives the fossil nonlinear heatstroke/hypothermia accumulation, linear recovery, severe-risk crossings, and ordinary exactly-once destruction with a typed cause; Eve exposes cockpit, risk, heatstroke source-weight, phasing and death-transition facts; EveUnity generically resolves the original severe pulse plus live/reconnect-safe cause-specific death crossfade; Aetheria deterministically translates the five broken legacy profiles into clean URP profiles, advertises them by semantic role through CultMesh CDN, and binds them in the canonical client through a weight-only native sink; rotated equipment topology, parent/child radiation, schematic composition, legacy SSR/AO/roundness equivalents, canonical render-pipeline activation and rendered parity remain incomplete | multi-consumer ordering, multi-radiator visibility, rotated topology, generic schematic meters, renderer-feature parity, active URP capture and live/reconnect death-fade screenshots |
| 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; shield contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; 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; the warm released witness captures full power and visible beam particles; the generic Unity witness also advances fixed daemon steps and observes Ymir contact remove the starter salvage | polish provider beam shape/attachment, rejected-capacity feedback, and explicit cargo-delta witness fact |
| 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; the warm released witness proves one pickup becomes zero after one Ymir Begin fact, one `pickup.collected` event, and an exact cargo delta from `0` to `1`; capacity rejection publishes `cargo-capacity` and unchanged cargo through Eve in the daemon smoke | polish provider beam shape/attachment and add a released-client capacity-rejection scenario |
| 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 |
| 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 |

View file

@ -20,8 +20,8 @@ $expected = @{
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.2",
"140e1bd963a0033e66777a3b2c5fe6e9c97dfe32")
"org.gamecult.eve.unity-scene" = @(
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.31",
"140e1bd963a0033e66777a3b2c5fe6e9c97dfe32")
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.32",
"817912a041ac1911e1e27a4b88617754d90ad4b7")
}
foreach ($packageName in $expected.Keys) {