Move Eve state-ref resolution out of state reader

This commit is contained in:
Meta Vens 2026-06-28 03:08:54 +01:00
commit fb4cf4f39a
3 changed files with 216 additions and 108 deletions

View file

@ -9283,7 +9283,7 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
"VerseHostSettingsAsync()",
"AetheriaRuntimeLoadoutTemplatesDocument",
"CreateEveSurfaceStateRefResolver(",
"AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver(",
"AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(",
"SubmitDaemonCommandAsync(",
"SubmitEveCommandAsync(",
"AetheriaRuntimeVerseRecordKeys.DaemonCommand(command.CommandId)",
@ -9316,6 +9316,13 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
string.Join(", ", missingStateReaderSymbols));
}
if (client.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver", StringComparison.Ordinal) ||
client.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"AetheriaRuntimeVerseClient still routes Eve state-ref resolution through the file-backed compatibility reader.");
}
if (client.Contains("public async Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(", StringComparison.Ordinal) ||
client.Contains("public async Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync(", StringComparison.Ordinal))
{
@ -12725,6 +12732,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
var requiredReaderSymbols = new[]
{
"public static class AetheriaRuntimeStateReader",
"public static class AetheriaRuntimeStateRefResolver",
"OpenRuntimeCatalog",
"ReadPlayerSettings",
"ReadVerseHostSettings",
@ -12756,7 +12764,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
"ResolveSurfaceStateRefs(stateFilePath, surface)",
"public static Func<string, string> CreateEveSurfaceStateRefResolver(string stateFilePath)",
"public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(",
"private static CultMeshStateRefResolver CreateStateRefResolver(string stateFilePath, string runtimeId)",
"AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(",
"CultMeshStateRefResolver.Empty",
"CultMesh.StateRefResolver(",
".AsFunc()",
@ -13203,6 +13211,24 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
"Unity Eve surface host still resolves default state refs through the file reader instead of the managed runtime client provider.");
}
var runtimeVerseClientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs");
var runtimeVerseClient = File.Exists(runtimeVerseClientPath)
? File.ReadAllText(runtimeVerseClientPath)
: throw new InvalidOperationException("Cannot verify managed state-ref resolver ownership; AetheriaRuntimeVerseClient.cs is missing.");
if (!runtimeVerseClient.Contains("AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Managed Verse client no longer resolves Eve state refs through the typed runtime state-ref resolver.");
}
if (runtimeVerseClient.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver", StringComparison.Ordinal) ||
runtimeVerseClient.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Managed Verse client still routes Eve state-ref resolution through the file-backed compatibility reader.");
}
var forbiddenDirectStoreSymbols = new Dictionary<string, string[]>
{
[actionGameManagerPath] = new[]

View file

@ -118,16 +118,181 @@ namespace GameCult.Aetheria.State.Verse
public static string ResolveEveSurfaceStateRef(string stateFilePath, string stateRef)
{
return TryResolveEveSurfaceStateRef(stateFilePath, stateRef, out var value) ? value : "";
return AetheriaRuntimeStateRefResolver.ResolveEveSurfaceStateRef(
stateFilePath,
stateRef,
OpenRuntimeCatalog);
}
public static bool TryResolveEveSurfaceStateRef(string stateFilePath, string stateRef, out string value)
{
return AetheriaRuntimeStateRefResolver.TryResolveEveSurfaceStateRef(
stateFilePath,
stateRef,
OpenRuntimeCatalog,
out value);
}
public static bool TryResolveDaemonStateRef(
AetheriaRuntimeDaemonFrameDocument? frame,
AetheriaRuntimeDaemonHealthDocument? health,
AetheriaRuntimeDaemonCommandBoundaryDocument? commandBoundary,
string stateRef,
out string value)
{
return AetheriaRuntimeStateRefResolver.TryResolveDaemonStateRef(
frame,
health,
commandBoundary,
stateRef,
out value);
}
public static bool TryResolveDaemonItemStatRef(
AetheriaRuntimeDaemonFrameDocument? frame,
AetheriaRuntimeCatalogSnapshot? catalog,
string stateRef,
out string value)
{
return AetheriaRuntimeStateRefResolver.TryResolveDaemonItemStatRef(
frame,
catalog,
stateRef,
out value);
}
public static bool TryReadDaemonGameSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonGameTuiSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameTuiSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonEditorSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonEditorTuiSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorTuiSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
private static EveSurfaceDocument EmptySurface(string surfaceId)
{
return AetheriaRuntimeEveSurfaceAdapter.EmptySurface(surfaceId);
}
public static Func<string, string> CreateEveSurfaceStateRefResolver(string stateFilePath)
{
return CreateEveSurfaceCultMeshStateRefResolver(stateFilePath).AsFunc();
}
public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(
string stateFilePath,
string runtimeId = AetheriaRuntimeVerseClient.DefaultRuntimeId)
{
return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(
stateFilePath,
runtimeId,
OpenRuntimeCatalog);
}
public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(
AetheriaRuntimeDaemonFrameDocument? frame,
AetheriaRuntimeDaemonHealthDocument? health,
AetheriaRuntimeDaemonCommandBoundaryDocument? commandBoundary,
Func<AetheriaRuntimeCatalogSnapshot?>? catalogProvider = null,
CultMeshRouteHint? routeHint = null)
{
return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(
frame,
health,
commandBoundary,
catalogProvider,
routeHint);
}
private static EveSurfaceDocument ToResolvedEveSurfaceDocument(
string stateFilePath,
AetheriaRuntimeSurfaceDocument surface)
{
return AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
surface,
CreateEveSurfaceStateRefResolver(stateFilePath));
}
private static EveSurfaceDocument ResolveSurfaceStateRefs(
string stateFilePath,
EveSurfaceDocument surface)
{
return AetheriaRuntimeEveSurfaceAdapter.ResolveStateRefs(
surface,
CreateEveSurfaceStateRefResolver(stateFilePath));
}
}
public static class AetheriaRuntimeStateRefResolver
{
public static string ResolveEveSurfaceStateRef(
string stateFilePath,
string stateRef,
Func<string, AetheriaRuntimeCatalogSnapshot> catalogProvider)
{
return TryResolveEveSurfaceStateRef(stateFilePath, stateRef, catalogProvider, out var value) ? value : "";
}
public static bool TryResolveEveSurfaceStateRef(
string stateFilePath,
string stateRef,
Func<string, AetheriaRuntimeCatalogSnapshot> catalogProvider,
out string value)
{
value = "";
if (string.IsNullOrWhiteSpace(stateRef))
return false;
TryReadDaemonFrame(stateFilePath, out var frame);
AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out var frame);
if (stateRef.StartsWith(AetheriaRuntimeDaemonStateRefs.Prefix + "/", StringComparison.Ordinal))
{
AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health);
@ -139,7 +304,7 @@ namespace GameCult.Aetheria.State.Verse
{
return TryResolveDaemonItemStatRef(
frame,
OpenRuntimeCatalog(stateFilePath),
catalogProvider(stateFilePath),
stateRef,
out value);
}
@ -264,80 +429,28 @@ namespace GameCult.Aetheria.State.Verse
return true;
}
public static bool TryReadDaemonGameSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonGameTuiSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameTuiSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonEditorSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
public static bool TryReadDaemonEditorTuiSurface(
string stateFilePath,
out EveSurfaceDocument document)
{
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorTuiSurface(stateFilePath, out var surface))
{
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId);
return false;
}
document = ToResolvedEveSurfaceDocument(stateFilePath, surface);
return true;
}
private static EveSurfaceDocument EmptySurface(string surfaceId)
{
return AetheriaRuntimeEveSurfaceAdapter.EmptySurface(surfaceId);
}
public static Func<string, string> CreateEveSurfaceStateRefResolver(string stateFilePath)
{
return CreateEveSurfaceCultMeshStateRefResolver(stateFilePath).AsFunc();
}
public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(
string stateFilePath,
string runtimeId = AetheriaRuntimeVerseClient.DefaultRuntimeId)
string runtimeId,
Func<string, AetheriaRuntimeCatalogSnapshot> catalogProvider)
{
if (string.IsNullOrWhiteSpace(stateFilePath))
return CultMeshStateRefResolver.Empty;
return CreateStateRefResolver(stateFilePath, runtimeId);
AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out var frame);
AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health);
AetheriaRuntimeDaemonPublicationStore.TryReadCommandBoundary(stateFilePath, out var commandBoundary);
return CreateEveSurfaceCultMeshStateRefResolver(
frame,
health,
commandBoundary,
() => catalogProvider(stateFilePath),
new CultMeshRouteHint(
CultMeshLocalityKind.InProcess,
string.IsNullOrWhiteSpace(runtimeId)
? AetheriaRuntimeVerseClient.DefaultRuntimeId
: runtimeId));
}
public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(
@ -384,38 +497,6 @@ namespace GameCult.Aetheria.State.Verse
return daemonRefs.Or(itemStatRefs);
}
private static EveSurfaceDocument ToResolvedEveSurfaceDocument(
string stateFilePath,
AetheriaRuntimeSurfaceDocument surface)
{
return AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
surface,
CreateEveSurfaceStateRefResolver(stateFilePath));
}
private static EveSurfaceDocument ResolveSurfaceStateRefs(
string stateFilePath,
EveSurfaceDocument surface)
{
return AetheriaRuntimeEveSurfaceAdapter.ResolveStateRefs(
surface,
CreateEveSurfaceStateRefResolver(stateFilePath));
}
private static CultMeshStateRefResolver CreateStateRefResolver(string stateFilePath, string runtimeId)
{
TryReadDaemonFrame(stateFilePath, out var frame);
AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health);
AetheriaRuntimeDaemonPublicationStore.TryReadCommandBoundary(stateFilePath, out var commandBoundary);
return CreateEveSurfaceCultMeshStateRefResolver(
frame,
health,
commandBoundary,
() => OpenRuntimeCatalog(stateFilePath),
new CultMeshRouteHint(CultMeshLocalityKind.InProcess, runtimeId));
}
private static AetheriaRuntimeLoadoutItemCommit? FindDaemonItem(
AetheriaRuntimeRunCheckpointCommit? run,
string itemKey)

View file

@ -197,9 +197,10 @@ namespace GameCult.Aetheria.State.Verse
string statePath,
string runtimeId = DefaultRuntimeId)
{
return AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver(
return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(
statePath,
string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId);
string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId,
AetheriaRuntimeCatalogStore.OpenReadOnly);
}
public Task<AetheriaRuntimeDaemonProviderAdvertisementDocument?> GetProviderAdvertisementAsync()
@ -324,7 +325,7 @@ namespace GameCult.Aetheria.State.Verse
await Task.WhenAll(frameTask, healthTask, commandBoundaryTask).ConfigureAwait(false);
return AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver(
return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(
frameTask.Result,
healthTask.Result,
commandBoundaryTask.Result,