diff --git a/src/GameCult.Mesh/CultMesh.cs b/src/GameCult.Mesh/CultMesh.cs index 0c015818..5eefdaba 100644 --- a/src/GameCult.Mesh/CultMesh.cs +++ b/src/GameCult.Mesh/CultMesh.cs @@ -1839,7 +1839,6 @@ namespace GameCult.Mesh client.SendCultNet(new CultNetSnapshotRequestMessage { MessageId = messageId, - SchemaIds = new[] { descriptor.SchemaId }, RecordKeys = new[] { recordKey } }); diff --git a/src/GameCult.Mesh/docs/public-api.md b/src/GameCult.Mesh/docs/public-api.md index 7f5ef40f..52df0845 100644 --- a/src/GameCult.Mesh/docs/public-api.md +++ b/src/GameCult.Mesh/docs/public-api.md @@ -288,6 +288,11 @@ var health = await remoteHealth.LatestAsync(); var uiHealth = remoteHealth.AsSchemaAlias(); ``` +Snapshot requests are record-key-first so same logical documents can still be +read when another runtime generated a different schema id for a compatible +schema alias. The decode path prefers exact schema id matches when present and +falls back to the requested record key. + A domain facade can collect handles into one schema-aware catalog: ```csharp diff --git a/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs b/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs index fed12c54..9729d555 100644 --- a/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs +++ b/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading.Tasks; using FluentAssertions; using GameCult.Caching; +using GameCult.Caching.MessagePack; using GameCult.Networking; using MessagePack; using NUnit.Framework; @@ -887,9 +888,37 @@ public sealed class CultMeshStreamingTests handle.RouteHint.Kind.Should().Be(CultMeshLocalityKind.Network); handle.Sources.Should().ContainSingle().Which.SourceId.Should().Be(key.Value); requests.Should().ContainSingle(); - requests[0].SchemaIds.Should().ContainSingle().Which.Should().Be(handle.SchemaId); + requests[0].SchemaIds.Should().BeNull(); requests[0].RecordKeys.Should().ContainSingle().Which.Should().Be(key.Value); (await catalog.LatestAsync()).Text.Should().Be("remote-snapshot"); + + var aliasSchemaHandle = CultMesh.DocumentFromPeerSnapshot( + _ => Task.FromResult(new CultNetSnapshotResponseRawMessage + { + MessageId = "alias-schema", + Documents = new[] + { + new CultNetRawDocumentRecord + { + SchemaId = "remote.generated.mesh_note_alias.v99", + RecordKey = key.Value, + StoredAt = DateTimeOffset.UtcNow.ToString("O"), + PayloadEncoding = "messagepack", + Payload = CultDocumentMessagePackSerialization.SerializeUntyped( + new MeshNoteDocument + { + Schema = "tests.mesh_note.v1", + Text = "record-key-fallback", + Revision = 10 + }, + typeof(MeshNoteDocument)) + } + } + }), + key.Value, + CultMesh.Verse("starbridge", "unity-pilot")); + + (await aliasSchemaHandle.LatestAsync()).Text.Should().Be("record-key-fallback"); } [Test]