Delegate Aetheria document lookup to CultMesh
This commit is contained in:
parent
7a6172d34c
commit
1d41899f6f
3 changed files with 52 additions and 50 deletions
|
|
@ -340,7 +340,7 @@ const refit = await client.aetheria()
|
|||
|
||||
Work:
|
||||
|
||||
- Keep pushing shared CultMesh typed reactive document and collection handles down until type/schema lookup, including the current Aetheria facade shim for schema-compatible CLR aliases, is owned by CultMesh rather than by the Aetheria facade registry.
|
||||
- Keep pushing shared CultMesh typed reactive document and collection handles down. Typed document handles and schema-compatible CLR alias lookup now live in CultMesh through `CultMeshDocumentHandle<TDocument>` and `CultMeshDocumentCatalog`; remaining work should remove client-side joins and generated facade gaps rather than rebuilding schema dictionaries in Aetheria.
|
||||
- Generate Aetheria current/station/zone/catalog accessors from schema metadata.
|
||||
- Move derived-state joins, such as current docking bay from current docking plus station refit plus entity records, into generated/internal query executors.
|
||||
- Replace remaining Unity menu/HUD/render calls to `TryResolve*` and `_observedFacadeIndex` with typed handles or generated/internal render adapters.
|
||||
|
|
@ -351,7 +351,7 @@ Work:
|
|||
Gates:
|
||||
|
||||
- `InventoryMenu`, `InventoryPanel`, `TradeMenu`, `LocalMenu`, `SchematicDisplay`, `SectorRenderer`, `MapRenderer`, and `ZoneRenderer` do not manually join state projections to obtain domain values.
|
||||
- Shared projected documents are reachable through `client.Aetheria().Document<TDocument>()`, including same-schema CLR aliases, `client.Aetheria().DocumentBySchema(schemaVersion)`, `client.Aetheria().LatestAsync<TDocument>()`, and `client.Watch<TDocument>()` as the C# stepping stone toward CultMesh-native type/schema lookup.
|
||||
- Shared projected documents are reachable through `client.Aetheria().Document<TDocument>()`, including same-schema CLR aliases, `client.Aetheria().DocumentBySchema(schemaVersion)`, `client.Aetheria().LatestAsync<TDocument>()`, and `client.Watch<TDocument>()`; the underlying type/schema lookup is delegated to CultMesh rather than an Aetheria-owned schema registry.
|
||||
- Client-facing code contains no `_observedFacadeIndex.TryResolve*` outside Unity render adapter internals.
|
||||
- Client-facing code contains no `ResolveClient().Current*Async().GetAwaiter().GetResult()` or equivalent blocking state reads.
|
||||
- `TryGetTypedCurrentDockingBayFacade` and similar transitional helpers are deleted rather than renamed.
|
||||
|
|
|
|||
|
|
@ -596,16 +596,17 @@ Assert-Contains $verseClient "AetheriaClientState Aetheria()" "AetheriaRuntimeVe
|
|||
Assert-Contains $verseClient "CreateAetheriaStateFacade" "AetheriaRuntimeVerseClient must own projected state facade creation."
|
||||
|
||||
$clientState = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaClientState.cs"
|
||||
Assert-Contains $clientState "CultMeshBoundLiveFeed" "Aetheria state documents must bind through CultMesh live feeds."
|
||||
Assert-Contains $clientState "CultMeshDocumentHandle<TDocument>" "Aetheria state documents must wrap CultMesh typed document handles."
|
||||
Assert-Contains $clientState "CultMeshDocumentCatalog" "Aetheria state facade must delegate type/schema lookup to CultMesh."
|
||||
Assert-Contains $clientState "CultMesh.Documents" "Aetheria state facade must build its projected document catalog through CultMesh."
|
||||
Assert-Contains $clientState "IAetheriaRuntimeProjectedDocument" "Aetheria projected documents must expose schema metadata independent of exact CLR type."
|
||||
Assert-Contains $clientState "_documentsByType" "Aetheria state facade must index projected documents by shared document type."
|
||||
Assert-Contains $clientState "_documentsBySchema" "Aetheria state facade must index projected documents by shared schema identity."
|
||||
Assert-Contains $clientState "TryGetDocument<TDocument>" "Aetheria state facade must support safe typed document lookup."
|
||||
Assert-Contains $clientState "TryGetDocumentBySchema" "Aetheria state facade must support safe schema document lookup."
|
||||
Assert-Contains $clientState "Document<TDocument>()" "Aetheria state facade must support direct typed document lookup."
|
||||
Assert-Contains $clientState "DocumentBySchema(string schemaVersion)" "Aetheria state facade must support direct schema document lookup."
|
||||
Assert-Contains $clientState "AsSchemaAlias<TAlias>" "Aetheria state facade must adapt same-schema projected documents across CLR aliases until CultMesh owns alias conversion."
|
||||
Assert-Contains $clientState "CultDocumentMessagePackSerialization" "Aetheria projected document aliasing must use the canonical CultCache document serializer."
|
||||
Assert-Contains $clientState "AsSchemaAlias<TAlias>" "Aetheria state facade must expose CultMesh same-schema aliases."
|
||||
Assert-NotContains $clientState "CultDocumentMessagePackSerialization" "Aetheria projected document aliasing must be owned by CultMesh, not the Aetheria facade."
|
||||
Assert-Contains $clientState "LatestAsync<TDocument>()" "Aetheria state facade must support one-call typed document reads."
|
||||
Assert-Contains $clientState "Watch<TDocument>()" "Aetheria state facade must support reactive typed document lookup."
|
||||
Assert-Contains $clientState "LatestAsync()" "Aetheria state documents must support one-shot typed reads."
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Mesh;
|
||||
using R3;
|
||||
|
||||
|
|
@ -36,6 +36,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public CultMeshDocumentHandle<TDocument> Handle => _handle;
|
||||
|
||||
public ICultMeshDocumentHandle UntypedHandle => _handle;
|
||||
|
||||
public Task<TDocument> LatestAsync()
|
||||
{
|
||||
return _handle.LatestAsync();
|
||||
|
|
@ -109,13 +111,46 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
bool CanReplace { get; }
|
||||
|
||||
ICultMeshDocumentHandle UntypedHandle { get; }
|
||||
|
||||
AetheriaRuntimeProjectedDocument<TAlias> AsSchemaAlias<TAlias>() where TAlias : class;
|
||||
}
|
||||
|
||||
internal sealed class AetheriaRuntimeUntypedProjectedDocument : IAetheriaRuntimeProjectedDocument
|
||||
{
|
||||
private readonly ICultMeshDocumentHandle _handle;
|
||||
|
||||
public AetheriaRuntimeUntypedProjectedDocument(ICultMeshDocumentHandle handle)
|
||||
{
|
||||
_handle = handle ?? throw new ArgumentNullException(nameof(handle));
|
||||
}
|
||||
|
||||
public Type DocumentType => _handle.DocumentType;
|
||||
|
||||
public string DocumentId => _handle.DocumentId;
|
||||
|
||||
public string SchemaName => _handle.SchemaName;
|
||||
|
||||
public string SchemaVersion => _handle.SchemaVersion;
|
||||
|
||||
public CultMeshRouteHint RouteHint => _handle.RouteHint;
|
||||
|
||||
public System.Collections.Generic.IReadOnlyList<CultMeshProjectionSource> Sources => _handle.Sources;
|
||||
|
||||
public bool CanReplace => _handle.CanReplace;
|
||||
|
||||
public ICultMeshDocumentHandle UntypedHandle => _handle;
|
||||
|
||||
public AetheriaRuntimeProjectedDocument<TAlias> AsSchemaAlias<TAlias>() where TAlias : class
|
||||
{
|
||||
return new AetheriaRuntimeProjectedDocument<TAlias>(_handle.AsSchemaAlias<TAlias>());
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientState
|
||||
{
|
||||
private readonly IReadOnlyDictionary<Type, object> _documentsByType;
|
||||
private readonly IReadOnlyDictionary<string, IAetheriaRuntimeProjectedDocument> _documentsBySchema;
|
||||
private readonly CultMeshDocumentCatalog _documents;
|
||||
|
||||
internal AetheriaClientState(
|
||||
AetheriaRuntimeProjectedDocument<AetheriaRuntimeCurrentZoneDocument> currentZone,
|
||||
|
|
@ -141,7 +176,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[typeof(AetheriaRuntimeSectorMapDocument)] = SectorMap,
|
||||
[typeof(AetheriaRuntimeZoneRenderDocument)] = ZoneRender
|
||||
};
|
||||
_documentsBySchema = BuildSchemaIndex(_documentsByType.Values);
|
||||
_documents = CultMesh.Documents(_documentsByType
|
||||
.Values
|
||||
.OfType<IAetheriaRuntimeProjectedDocument>()
|
||||
.Select(document => document.UntypedHandle));
|
||||
}
|
||||
|
||||
public AetheriaClientCurrentState Current { get; }
|
||||
|
|
@ -158,9 +196,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
string schemaVersion,
|
||||
out IAetheriaRuntimeProjectedDocument document)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(schemaVersion) &&
|
||||
_documentsBySchema.TryGetValue(schemaVersion, out document!))
|
||||
if (_documents.TryGetDocumentBySchema(schemaVersion, out var handle))
|
||||
{
|
||||
document = new AetheriaRuntimeUntypedProjectedDocument(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -181,24 +219,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
out AetheriaRuntimeProjectedDocument<TDocument> document)
|
||||
where TDocument : class
|
||||
{
|
||||
if (_documentsByType.TryGetValue(typeof(TDocument), out var untypedDocument) &&
|
||||
untypedDocument is AetheriaRuntimeProjectedDocument<TDocument> typedDocument)
|
||||
if (_documents.TryGetDocument<TDocument>(out var handle))
|
||||
{
|
||||
document = typedDocument;
|
||||
return true;
|
||||
}
|
||||
|
||||
var schemaVersion = SchemaVersionFor(typeof(TDocument));
|
||||
if (!string.IsNullOrWhiteSpace(schemaVersion) &&
|
||||
_documentsBySchema.TryGetValue(schemaVersion, out var schemaDocument))
|
||||
{
|
||||
if (schemaDocument is AetheriaRuntimeProjectedDocument<TDocument> schemaTypedDocument)
|
||||
{
|
||||
document = schemaTypedDocument;
|
||||
return true;
|
||||
}
|
||||
|
||||
document = schemaDocument.AsSchemaAlias<TDocument>();
|
||||
document = new AetheriaRuntimeProjectedDocument<TDocument>(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -234,28 +257,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return Document<TDocument>().Watch(onNext);
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, IAetheriaRuntimeProjectedDocument> BuildSchemaIndex(
|
||||
IEnumerable<object> documents)
|
||||
{
|
||||
var index = new Dictionary<string, IAetheriaRuntimeProjectedDocument>(StringComparer.Ordinal);
|
||||
foreach (var document in documents)
|
||||
{
|
||||
if (document is not IAetheriaRuntimeProjectedDocument projectedDocument)
|
||||
continue;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(projectedDocument.SchemaVersion))
|
||||
index[projectedDocument.SchemaVersion] = projectedDocument;
|
||||
if (!string.IsNullOrWhiteSpace(projectedDocument.SchemaName))
|
||||
index[projectedDocument.SchemaName] = projectedDocument;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
private static string SchemaVersionFor(Type documentType)
|
||||
{
|
||||
return CultDocumentRegistry.Shared.GetRequired(documentType).SchemaVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientCurrentState
|
||||
|
|
|
|||
Loading…
Reference in a new issue