Prove typed zone entity state

This commit is contained in:
Meta Vens 2026-06-13 10:36:41 +01:00
commit e51a77932c
5 changed files with 112 additions and 7 deletions

Binary file not shown.

View file

@ -11,6 +11,8 @@ var factionLegacyId = "smoke:faction";
var nameFileLegacyId = "smoke:name-file";
var runKey = new CultRecordKey("run:smoke");
var loadoutKey = new CultRecordKey("loadout:smoke:aether-runner");
var zoneKey = new CultRecordKey("zone:smoke:0");
var entityKey = new CultRecordKey("entity:smoke:runner");
await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-state-smoke"))
{
@ -122,6 +124,51 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
}
});
await node.PutEntitySnapshotAsync(entityKey, new AetheriaEntitySnapshot
{
Name = "Smoke Aether Runner",
Kind = "ship",
Position = new AetheriaVector3 { X = 12.5, Y = 0.0, Z = -3.25 },
Direction = new AetheriaVector2 { X = 0.0, Y = 1.0 },
FactionKey = AetheriaCatalogKeys.CorporationFromLegacyId(factionLegacyId).ToString(),
HullItemKey = AetheriaCatalogKeys.ItemDefinitionFromLegacyId(itemLegacyId).ToString(),
Equipment =
[
new AetheriaEntityItemSlot
{
Position = new AetheriaGridCoord { X = 0, Y = 0 },
ItemKey = AetheriaCatalogKeys.ItemDefinitionFromLegacyId(itemLegacyId).ToString()
}
],
WeaponGroups =
[
new AetheriaWeaponGroupSnapshot
{
EquipmentIndices = [0]
}
],
StatGrids =
[
new AetheriaEntityStatGrid
{
Name = "armor",
Width = 2,
Height = 2,
Values = [1.0, 0.9, 0.8, 0.7]
}
]
});
await node.PutZoneStateAsync(zoneKey, new AetheriaZoneState
{
Name = "Smoke Zone",
Position = new AetheriaVector2 { X = 4.0, Y = 8.0 },
AdjacentZoneIndices = [1],
FactionIndices = [0],
OwnerFactionIndex = 0,
EntityKeys = [entityKey.ToString()]
});
await node.PutRunStateAsync(runKey, new AetheriaRunState
{
RunId = "smoke",
@ -131,6 +178,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
CurrentZoneIndex = 0,
CurrentZoneEntityIndex = 0,
DiscoveredZoneIndices = [0],
ZoneKeys = [zoneKey.ToString()],
ActionBarBindings =
[
new AetheriaActionBarBinding
@ -195,6 +243,8 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
var playerSettings = await reopened.GetPlayerSettingsAsync();
var loadout = await reopened.GetLoadoutTemplateAsync(loadoutKey);
var runState = await reopened.GetRunStateAsync(runKey);
var zoneState = await reopened.GetZoneStateAsync(zoneKey);
var entitySnapshot = await reopened.GetEntitySnapshotAsync(entityKey);
if (world?.WorldId != "aetheria")
{
@ -246,10 +296,29 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
throw new InvalidOperationException("Loadout template did not survive flush/reopen.");
}
if (runState?.RunId != "smoke" || runState.ActionBarBindings.Length != 1)
if (runState?.RunId != "smoke" ||
runState.ZoneKeys.Length != 1 ||
runState.ActionBarBindings.Length != 1)
{
throw new InvalidOperationException("Run state did not survive flush/reopen.");
}
if (zoneState?.EntityKeys.Length != 1 ||
zoneState.EntityKeys[0] != entityKey.ToString() ||
zoneState.Position.X != 4.0 ||
zoneState.OwnerFactionIndex != 0)
{
throw new InvalidOperationException("Zone state did not survive flush/reopen.");
}
if (entitySnapshot?.Kind != "ship" ||
entitySnapshot.Equipment.Length != 1 ||
entitySnapshot.WeaponGroups.Length != 1 ||
entitySnapshot.StatGrids.Length != 1 ||
entitySnapshot.StatGrids[0].Values.Length != 4)
{
throw new InvalidOperationException("Entity snapshot did not survive flush/reopen.");
}
}
Console.WriteLine($"Aetheria typed state smoke passed: {statePath}");

View file

@ -205,6 +205,28 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
return Database.GetAsync<AetheriaRunState>(key);
}
public Task<CultRecordHandle<AetheriaZoneState>> PutZoneStateAsync(CultRecordKey key, AetheriaZoneState zone)
{
return Database.PutAsync(key, zone);
}
public Task<AetheriaZoneState?> GetZoneStateAsync(CultRecordKey key)
{
return Database.GetAsync<AetheriaZoneState>(key);
}
public Task<CultRecordHandle<AetheriaEntitySnapshot>> PutEntitySnapshotAsync(
CultRecordKey key,
AetheriaEntitySnapshot entity)
{
return Database.PutAsync(key, entity);
}
public Task<AetheriaEntitySnapshot?> GetEntitySnapshotAsync(CultRecordKey key)
{
return Database.GetAsync<AetheriaEntitySnapshot>(key);
}
public Task FlushAsync(bool soft = false)
{
return _node.FlushAsync(soft);

View file

@ -92,9 +92,11 @@ objects and does not write state. Unity can use this as the first package
boundary once CultLib/Eve runtime packaging is available.
`Aetheria.State.Smoke` writes and reopens full typed player settings plus a
typed loadout template in addition to world, catalog, and run state. That smoke
is the current proof that settings and loadouts have durable Verse state shapes
without reviving `PlayerSettings.msgpack` or `.loadout` serialization.
typed loadout template in addition to world, catalog, run state, zone state, and
an entity snapshot. The run smoke proves a typed run can reference a typed zone,
the zone can reference typed entity snapshots, and entity snapshots can preserve
equipment slots, weapon groups, and stat grids without reviving
`PlayerSettings.msgpack`, `.loadout`, or `.zone` serialization.
`Aetheria.State.Verify` opens a materialized state file and checks that the
typed migration ledger matches the actual item, corporation, and name-file

View file

@ -45,6 +45,13 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
preferences, input binding overrides, and action-bar inputs. Unity's menu and
input screens still mutate the old `PlayerSettings` runtime object in memory
until the runtime Verse package is wired.
- `Aetheria.State` now exposes typed node put/get ports for run state, zone
state, and entity snapshots. The state smoke writes a run referencing a zone,
a zone referencing an entity snapshot, and an entity snapshot carrying
position, direction, faction, hull, equipment slots, weapon groups, and a stat
grid. This proves the `.zone` replacement graph is durable typed state; Unity
`ZonePack` and `EntityPack` are still runtime construction projections until
the runtime package is wired.
- `Aetheria.State` now defines `AetheriaLoadoutTemplate` as the typed Verse
replacement for bespoke `.loadout` files. It stores structured hull,
equipment, cargo bay, docking bay, child-entity, assignment, and weapon-group
@ -177,8 +184,10 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
methods, not importer-local string concatenation. Player settings and loadout
templates have typed state documents and node put/get paths; Unity's menu,
input screens, and save button still need to call them through the runtime
Verse package. The catalog operator UI is emitted as a typed Eve surface
document derived from the catalog snapshot.
Verse package. Run, zone, and entity snapshot state also have typed node
put/get paths; Unity `SaveState`/`SaveZone` still need to commit through those
ports. The catalog operator UI is emitted as a typed Eve surface document
derived from the catalog snapshot.
- Derived state: UI panels, generated keyboard layouts, editor rows, and
serialized legacy payloads are projections, migration inputs, or disabled
session-local DTOs, not durable authority.
@ -294,6 +303,8 @@ First Aetheria surfaces to publish:
values.
- Done: add typed `AetheriaLoadoutTemplate` documents and smoke coverage so
`.loadout` no longer lacks a durable Verse replacement.
- Done: add typed node ports and smoke coverage for run -> zone -> entity
snapshots so `.zone` no longer lacks a durable Verse replacement graph.
- Remaining: add typed documents/mappers for runtime object graphs,
typed behavior factory construction, simulation state, and any catalog
fields not covered by the stable scalar/fingerprint/payload pass.
@ -352,7 +363,8 @@ First Aetheria surfaces to publish:
maintained projects.
- CultCache smoke proves write, flush, reopen, query, and typed reference
resolution, including full player settings as the `PlayerSettings.msgpack`
replacement and loadout templates as the `.loadout` replacement.
replacement, loadout templates as the `.loadout` replacement, and a run ->
zone -> entity snapshot graph as the `.zone` replacement.
- CultMesh smoke proves node start, typed put/get, subscription, flush, and
reopen.
- Eve surface smoke proves provider-owned surface documents are generated from