Mesh: a zero-byte store file is refused, not read as empty; the alias test is retargeted to one type per schema

CultMesh's single-file reader had its own zero-length-means-empty branch, so a Mesh write
replaced a zero-byte file the cache refuses (merge-r1-precedence). It now asks the cache's
snapshot reader and gets its verdict. The auto-merged test that read a same-schema instance
through MeshNoteAliasDocument cannot be built under retire-schema-alias; it now states the
ownership rule it protected (a database serves only what a shard owns) with the one type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-02 20:49:12 +02:00
commit 75ba6c0f5c
3 changed files with 15 additions and 6 deletions

View file

@ -276,8 +276,6 @@ namespace GameCult.Mesh
private static CultPersistedStoreSnapshot ReadSingleFileSnapshot(string path)
{
var bytes = File.ReadAllBytes(path);
if (bytes.Length == 0)
return new CultPersistedStoreSnapshot();
CultPersistedStoreSnapshot snapshot;
try
{

View file

@ -82,6 +82,17 @@ public sealed class CultMeshSingleFileReadabilityTests
}
}
// A read asks the same reader as a write: a file this runtime cannot read, a zero-byte one included, is refused as unreadable
// and never reported as a store that lacks the record.
[Test]
public void AReadOfAZeroByteFileIsRefusedAsUnreadableNotAsAMissingRecord()
{
var path = Path.Combine(_root, "zero.cc");
File.WriteAllBytes(path, Array.Empty<byte>());
Assert.That(() => CultMesh.ReadSingleFileDocumentPayload(path, new CultRecordKey("publication"), "raw:schema"), Throws.TypeOf<CultStoreUnreadableException>());
}
[Test]
public void EveryVectorInTheFolderHasAManifestRow()
{

View file

@ -902,11 +902,11 @@ public sealed class CultMeshStreamingTests
await act.Should().ThrowAsync<NotSupportedException>();
}
// A database serves only what its shards own, including when a handle reads a same-schema instance of another CLR type
// out of the cache behind it.
// A database serves only what its shards own. A schema has one CLR type (retire-schema-alias), so there is no second type
// that could reach a record around the shard that owns its schema.
[TestCase("tests.mesh_note.v1", true)]
[TestCase("tests.unrelated.v1", false)]
public async Task DocumentHandle_ReadsASameSchemaInstanceOnlyWhenAShardOwnsIt(string ownedSchemaId, bool served)
public async Task DocumentHandle_ReadsARecordOnlyWhenAShardOwnsItsSchema(string ownedSchemaId, bool served)
{
var cache = new CultCache();
var key = new CultRecordKey("note:one");
@ -916,7 +916,7 @@ public sealed class CultMeshStreamingTests
RuntimeId = "reader",
Shards = new[] { new CultNetShardDescriptor("notes", "reader", epoch: 1, isPrimary: true, schemaIds: new[] { ownedSchemaId }) }
});
var handle = CultMesh.Document<MeshNoteAliasDocument>(database, key, CultMesh.Verse("starbridge", "reader"));
var handle = CultMesh.Document<MeshNoteDocument>(database, key, CultMesh.Verse("starbridge", "reader"));
if (served)
{