From 6fb0e22c412c9d9bbddc1acc3d34846eb1f8e2e3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 27 Oct 2026 07:17:04 +0100 Subject: [PATCH] Tests: pin the unpublished-id rule at Owns (a store file cannot hold such a record) ReadStore refuses a record whose schema the catalog does not publish, so the file-level scenario the spec named cannot be built; the rule is pinned where it is decided. Co-Authored-By: Claude Sonnet 5.5 --- .../RestampOnWriteTests.cs | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs b/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs index f7170bfd..547f9def 100644 --- a/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs +++ b/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs @@ -493,26 +493,17 @@ namespace GameCult.Caching.Tests Assert.That(Snapshot(path).Records.Single(record => record.Key == "note").SchemaId, Is.EqualTo(NarrowRegistry.GetRequired().SchemaId)); } - // A durable record under an id no catalog entry publishes belongs to nobody a writer can name: another key's write carries it - // untouched, a write at its own key is refused. + // An id no catalog entry publishes belongs to nobody a writer can name, so no writer owns it. A store file cannot hold such a + // record (ReadStore refuses it), so the rule is pinned where it is decided, for a cacheless writer's lookup. [Test] - public void AnUnpublishedIdIsCarriedByACachelessWrite() + public void AnUnpublishedIdIsOwnedByNoOne() { - var path = SeedNarrow(directory: false); - var snapshot = Snapshot(path); - var stray = new CultPersistedRecord { Key = "stray", SchemaId = "tests.restamp.unpublished", StoredAt = snapshot.Records[0].StoredAt, Payload = new byte[] { 0x90 } }; - snapshot.Records = snapshot.Records.Concat(new[] { stray }).ToArray(); - File.WriteAllBytes(path, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot)); + var narrow = NarrowRegistry.GetRequired().ToCatalogEntry(); + var writes = new[] { narrow }; + Func declares = id => id == narrow.SchemaId; - new SingleFileMessagePackBackingStore(path).WriteDocument(Other, new NoteNarrow { Name = "other", Value = 3 }, registry: NarrowRegistry); - - var carried = Snapshot(path).Records.Single(record => record.Key == "stray"); - Assert.That(carried.SchemaId, Is.EqualTo("tests.restamp.unpublished")); - Assert.That(carried.Payload, Is.EqualTo(new byte[] { 0x90 })); - var before = Fingerprint(path); - Assert.Throws(() => - new SingleFileMessagePackBackingStore(path).WriteDocument(new CultRecordKey("stray"), new NoteNarrow { Name = "stray", Value = 1 }, registry: NarrowRegistry)); - Assert.That(Fingerprint(path), Is.EqualTo(before)); + Assert.That(CultDocumentRegistry.Owns("tests.restamp.unpublished", writes, declares, new CatalogEntryLookup(writes), entry => entry), Is.False); + Assert.That(CultDocumentRegistry.Owns(narrow.SchemaId, writes, declares, new CatalogEntryLookup(writes), entry => entry), Is.True); } private static string VectorPath(string name)