CultMesh: the untyped same-schema fallback reads through the database, which serves only what its shards own

The string ResolveShard check was order-dependent in the full Mesh suite (schema id of a same-schema alias pair); GetAsync<object> uses the descriptor path and adds no helper.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 07:28:30 +02:00
commit 784dc7d614

View file

@ -3370,20 +3370,6 @@ namespace GameCult.Mesh
$"CultMesh document '{key.Value}' was not found as {typeof(TDocument).FullName}.");
}
// A database serves only what its shards own; the cache behind it may hold more.
private static bool DatabaseServes(CultNetDatabase database, object document, CultRecordKey key)
{
try
{
database.ResolveShard(CultDocumentRegistry.Shared.GetRequired(document.GetType()).SchemaId, key);
return true;
}
catch (CultNetUnownedSchemaException)
{
return false;
}
}
private static async Task<TDocument> ReadDatabaseDocumentRequiredAsync<TDocument>(
CultNetDatabase database,
CultRecordKey key)
@ -3393,8 +3379,9 @@ namespace GameCult.Mesh
if (document != null)
return document;
var untyped = database.Cache.Get(key);
if (untyped != null && IsSameCultDocumentSchema<TDocument>(untyped.GetType()) && DatabaseServes(database, untyped, key))
// Through the database, which serves only what its shards own; the cache behind it may hold more.
var untyped = await database.GetAsync<object>(key).ConfigureAwait(false);
if (untyped != null && IsSameCultDocumentSchema<TDocument>(untyped.GetType()))
return ConvertUntypedDocument<TDocument>(untyped);
throw new KeyNotFoundException(