Publish typed catalog Eve surface

This commit is contained in:
Meta Vens 2026-06-13 08:37:10 +01:00
commit 88af85bddd
153 changed files with 415 additions and 149 deletions

Binary file not shown.

View file

@ -122,6 +122,8 @@ foreach (var nameFile in parsedNameFiles)
await node.PutLegacyNameFileAsync(nameFile);
}
await node.PutCatalogSurfaceAsync(AetheriaCatalogSurfaceProjector.Build(node.ReadCatalogSnapshot(), capturedAtUtc));
await node.FlushAsync();
Console.WriteLine($"Aetheria legacy catalog mapped into typed state: {statePath}");

View file

@ -84,6 +84,9 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
SampleNames = ["Ada", "Grace"]
});
await node.PutCatalogSurfaceAsync(
AetheriaCatalogSurfaceProjector.Build(node.ReadCatalogSnapshot(), now));
await node.PutRunStateAsync(runKey, new AetheriaRunState
{
RunId = "smoke",
@ -120,6 +123,7 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
var faction = await reopened.GetCorporationByLegacyIdAsync(factionLegacyId);
var nameFile = await reopened.GetNameFileByLegacyIdAsync(nameFileLegacyId);
var quarantine = await reopened.GetLegacyCatalogQuarantineAsync();
var catalogSurface = await reopened.GetCatalogSurfaceAsync();
var playerSettings = await reopened.GetPlayerSettingsAsync();
var runState = await reopened.GetRunStateAsync(runKey);
@ -148,6 +152,12 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
throw new InvalidOperationException("Legacy catalog quarantine did not survive flush/reopen.");
}
if (catalogSurface?.Schema != "gamecult.eve.surface.v1" ||
catalogSurface.Surface.Id != AetheriaCatalogSurfaceProjector.SurfaceId)
{
throw new InvalidOperationException("Eve catalog surface did not survive flush/reopen.");
}
if (playerSettings?.ActiveRunKey != runKey.ToString())
{
throw new InvalidOperationException("Player settings did not survive flush/reopen.");

View file

@ -12,11 +12,14 @@ var ledger = await node.GetMigrationLedgerAsync()
?? throw new InvalidOperationException("Missing typed migration ledger.");
var quarantine = await node.GetLegacyCatalogQuarantineAsync()
?? throw new InvalidOperationException("Missing legacy catalog quarantine document.");
var publishedSurface = await node.GetCatalogSurfaceAsync()
?? throw new InvalidOperationException("Missing Aetheria catalog Eve surface document.");
var items = node.Cache.GetAll<AetheriaItemDefinition>().ToArray();
var corporations = node.Cache.GetAll<AetheriaCorporation>().ToArray();
var nameFiles = node.Cache.GetAll<AetheriaNameFile>().ToArray();
var catalog = node.ReadCatalogSnapshot();
var surface = AetheriaCatalogSurfaceProjector.Build(catalog, DateTimeOffset.UtcNow.ToString("O"));
RequireCount(ledger, "aetheria.item_definition.v1", items.Length);
RequireCount(ledger, "aetheria.corporation.v1", corporations.Length);
@ -92,6 +95,20 @@ if (catalog.GetNameFile(corporationWithNames) == null)
$"Typed catalog name-file lookup failed for corporation {corporationWithNames.Name}.");
}
if (surface.Schema != "gamecult.eve.surface.v1" ||
surface.Surface.Root.Kind != "surface" ||
surface.Surface.Root.Children.Length == 0)
{
throw new InvalidOperationException("Aetheria catalog Eve surface projection is not renderable.");
}
if (publishedSurface.Schema != surface.Schema ||
publishedSurface.Surface.Id != AetheriaCatalogSurfaceProjector.SurfaceId ||
publishedSurface.Surface.Root.Kind != "surface")
{
throw new InvalidOperationException("Published Aetheria catalog Eve surface is not the expected typed surface.");
}
await RequireLegacyLookupAsync(
items[0].LegacyId,
() => node.GetItemDefinitionByLegacyIdAsync(items[0].LegacyId),
@ -115,6 +132,7 @@ Console.WriteLine($"Catalog fingerprint: {quarantine.CatalogFingerprint}");
Console.WriteLine($"Item definitions: {items.Length}");
Console.WriteLine($"Priced/manufactured/shaped items: {pricedItems}/{manufacturedItems}/{shapedItems}");
Console.WriteLine($"Typed catalog trade items: {tradeItems.Length}");
Console.WriteLine($"Eve catalog surface: {surface.Surface.Id} ({surface.Surface.Root.Children.Length} root children)");
Console.WriteLine($"Corporations: {corporations.Length}");
Console.WriteLine($"Described/geoname-linked corporations: {describedCorporations}/{corporationNameLinks}");
Console.WriteLine($"Name files: {nameFiles.Length}");

View file

@ -0,0 +1,108 @@
using System;
using System.Linq;
using Aetheria.State.Documents;
namespace Aetheria.State;
public static class AetheriaCatalogSurfaceProjector
{
public const string SurfaceKey = "eve:surface:aetheria.catalog.operator";
public const string SurfaceId = "aetheria.catalog.operator";
public static EveSurfaceState Build(AetheriaCatalogSnapshot catalog, string updatedAtUtc, long version = 1)
{
var tradeItems = catalog.TradeItems.Take(12).Select(item =>
Row(
$"item.{SafeId(item.LegacyId)}",
("name", item.Name),
("manufacturer", catalog.GetManufacturer(item)?.Name ?? "GameCult"),
("price", item.Price.ToString("N0")),
("size", item.ShapeWidth > 0 && item.ShapeHeight > 0 ? $"{item.ShapeWidth}x{item.ShapeHeight}" : "")))
.ToArray();
var corporations = catalog.Corporations.Take(12).Select(corporation =>
Row(
$"corporation.{SafeId(corporation.LegacyId)}",
("name", corporation.Name),
("short", corporation.ShortName),
("names", catalog.GetNameFile(corporation)?.Name ?? ""),
("influence", corporation.InfluenceDistance.ToString())))
.ToArray();
return new EveSurfaceState
{
ProviderId = "aetheria",
ProviderKind = "game.runtime",
Title = "Aetheria Catalog",
Version = version,
UpdatedAtUtc = updatedAtUtc,
Surface = new EveSurface
{
Id = SurfaceId,
Root = Node(
"aetheria.catalog.root",
"surface",
[],
Node(
"aetheria.catalog.summary",
"grid",
[("columns", "4")],
Metric("summary.items", "Items", catalog.Items.Count.ToString()),
Metric("summary.trade", "Trade Items", catalog.TradeItems.Count().ToString()),
Metric("summary.corporations", "Corporations", catalog.Corporations.Count.ToString()),
Metric("summary.nameFiles", "Name Files", catalog.NameFiles.Count.ToString())),
Node(
"aetheria.catalog.trade",
"card",
[("title", "Trade Catalog")],
Node("aetheria.catalog.trade.rows", "inspector.kv", [], tradeItems)),
Node(
"aetheria.catalog.corporations",
"card",
[("title", "Corporations")],
Node("aetheria.catalog.corporation.rows", "inspector.kv", [], corporations)))
},
Commands =
[
new EveCommandTemplate
{
Command = "aetheria.catalog.refresh",
Label = "Refresh",
Transport = "cultmesh"
}
]
};
}
private static EveSurfaceComponent Metric(string id, string label, string value)
{
return Node(id, "metric", [("label", label), ("value", value)]);
}
private static EveSurfaceComponent Row(string id, params (string Key, string Value)[] props)
{
return Node(id, "row", props);
}
private static EveSurfaceComponent Node(
string id,
string kind,
(string Key, string Value)[] props,
params EveSurfaceComponent[] children)
{
return new EveSurfaceComponent
{
Id = id,
Kind = kind,
Props = props.ToDictionary(prop => prop.Key, prop => prop.Value),
Children = children
};
}
private static string SafeId(string value)
{
return string.IsNullOrWhiteSpace(value)
? "empty"
: new string(value.Select(character => char.IsLetterOrDigit(character) ? character : '.').ToArray());
}
}

View file

@ -35,7 +35,8 @@ public static class AetheriaDocumentRegistry
CultNetDocumentBinding.ForDocument<AetheriaPlayerSettings>(registry),
CultNetDocumentBinding.ForDocument<AetheriaRunState>(registry),
CultNetDocumentBinding.ForDocument<AetheriaZoneState>(registry),
CultNetDocumentBinding.ForDocument<AetheriaEntitySnapshot>(registry)
CultNetDocumentBinding.ForDocument<AetheriaEntitySnapshot>(registry),
CultNetDocumentBinding.ForDocument<EveSurfaceState>(registry)
});
}
@ -52,6 +53,7 @@ public static class AetheriaDocumentRegistry
typeof(AetheriaPlayerSettings),
typeof(AetheriaRunState),
typeof(AetheriaZoneState),
typeof(AetheriaEntitySnapshot)
typeof(AetheriaEntitySnapshot),
typeof(EveSurfaceState)
];
}

View file

@ -163,6 +163,16 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
Cache.GetAll<AetheriaNameFile>());
}
public Task<CultRecordHandle<EveSurfaceState>> PutCatalogSurfaceAsync(EveSurfaceState surface)
{
return Database.PutAsync(new CultRecordKey(AetheriaCatalogSurfaceProjector.SurfaceKey), surface);
}
public Task<EveSurfaceState?> GetCatalogSurfaceAsync()
{
return Database.GetAsync<EveSurfaceState>(new CultRecordKey(AetheriaCatalogSurfaceProjector.SurfaceKey));
}
public Task<CultRecordHandle<AetheriaPlayerSettings>> PutPlayerSettingsAsync(AetheriaPlayerSettings settings)
{
return Database.PutAsync(new CultRecordKey("global:aetheria.player_settings.v1"), settings);

View file

@ -0,0 +1,92 @@
using GameCult.Caching;
using MessagePack;
namespace Aetheria.State.Documents;
[CultDocument("gamecult.eve.surface", "gamecult.eve.surface.v1")]
[MessagePackObject]
public sealed class EveSurfaceState
{
[Key(0)]
public string Type { get; set; } = "surface-state";
[Key(1)]
[CultIndex("schema")]
public string Schema { get; set; } = "gamecult.eve.surface.v1";
[Key(2)]
[CultIndex("providerId")]
public string ProviderId { get; set; } = "";
[Key(3)]
[CultIndex("providerKind")]
public string ProviderKind { get; set; } = "";
[Key(4)]
[CultName]
public string Title { get; set; } = "";
[Key(5)]
public long Version { get; set; }
[Key(6)]
public string UpdatedAtUtc { get; set; } = "";
[Key(7)]
public EveSurface Surface { get; set; } = new();
[Key(8)]
public EveCommandTemplate[] Commands { get; set; } = [];
}
[MessagePackObject]
public sealed class EveSurface
{
[Key(0)]
public string Id { get; set; } = "";
[Key(1)]
public EveSurfaceComponent Root { get; set; } = new();
[Key(2)]
public EveStyleToken[] Styles { get; set; } = [];
}
[MessagePackObject]
public sealed class EveSurfaceComponent
{
[Key(0)]
public string Id { get; set; } = "";
[Key(1)]
public string Kind { get; set; } = "";
[Key(2)]
public Dictionary<string, string> Props { get; set; } = new();
[Key(3)]
public EveSurfaceComponent[] Children { get; set; } = [];
}
[MessagePackObject]
public sealed class EveStyleToken
{
[Key(0)]
public string Name { get; set; } = "";
[Key(1)]
public string Value { get; set; } = "";
}
[MessagePackObject]
public sealed class EveCommandTemplate
{
[Key(0)]
public string Command { get; set; } = "";
[Key(1)]
public string Label { get; set; } = "";
[Key(2)]
public string Transport { get; set; } = "cultmesh";
}

View file

@ -60,13 +60,20 @@ documents. It exposes trade items, legacy-ID lookup, manufacturer lookup,
corporation prefix lookup, and corporation name-file lookup without reading
`DatabaseEntry` objects.
`AetheriaCatalogSurfaceProjector` publishes the first Eve-compatible provider
surface from typed catalog state. The importer materializes
`gamecult.eve.surface.v1` at `eve:surface:aetheria.catalog.operator` with
summary, trade-catalog, and corporation views. This is a typed CultCache
provider document and a local mirror of the Eve contract until the shared Eve
Unity UI Toolkit lowering package exists.
`Aetheria.State.Verify` opens a materialized state file and checks that the
typed migration ledger matches the actual item, corporation, and name-file
records in the `.cc` store. It also verifies the canonical legacy-ID lookup API
for one migrated record of each catalog kind and checks that expanded item and
corporation catalog facts survived materialization. The verifier also exercises
the typed catalog snapshot query surface. Use it after import when
`GameData/aetheria-world.cc` changes.
the typed catalog snapshot query surface and the published Eve catalog surface.
Use it after import when `GameData/aetheria-world.cc` changes.
Current rebuild notes:

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more