Land fixes: directory flush records the schema id it wrote; ported drift and variant tests meet C2a's write set and typed refusal

Directory store now sets StoredSchemaId with StoredVersion after a page write (found by main's OwnPushOfALoadedDriftedEntryKeepsExpectHolding). RecordRewrittenUnderAnotherSchema stages the record, since a flush writes only the write set. Variant conflict test expects CultWriteConflictException.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-22 20:59:54 +02:00
commit f2cdb7897d
3 changed files with 6 additions and 2 deletions

View file

@ -341,6 +341,7 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
var pagePayload = CultDocumentMessagePackSerialization.SerializePersistedRecord(record);
var indexRecord = ToContentAddressedIndexRecord(record, pagePayload);
stored.StoredVersion = VersionOf(indexRecord.Payload);
stored.StoredSchemaId = stored.Descriptor.SchemaId;
currentIndex[key] = indexRecord;
WriteFileAtomically(
ContentAddressedRecordPath(indexRecord),

View file

@ -90,7 +90,10 @@ namespace GameCult.Caching.Tests
var observed = cache.Get(DriftKey)!;
var storedAt = cache.GetStored(DriftKey)!.StoredAt;
using (var other = Drift(false, ReusedDrift).Open())
{
other.BackingStores[0].Push(other.GetStored(DriftKey)!);
other.BackingStores[0].PushAll();
}
using (var reader = Drift(false, ReusedDrift).Open())
Assert.That(reader.GetStored(DriftKey)!.StoredAt, Is.EqualTo(storedAt), "the rewrite kept storedAt");

View file

@ -1256,7 +1256,7 @@ namespace GameCult.Caching.Tests
using (var w = Open(path))
Assert.That(w.Commit(batch => batch.Upsert(typeof(VariantGear), Named("x", "l1"), BaseKey)), Is.True);
var refused = Refused(() => a.Commit(batch =>
var refused = Assert.Throws<CultWriteConflictException>(() => a.Commit(batch =>
{
batch.Expect(other, a.Get(other));
batch.UpsertVariant(BigKey, BaseKey, new[]
@ -1264,7 +1264,7 @@ namespace GameCult.Caching.Tests
a.Override<VariantGear>(nameof(VariantGear.Name), "x"),
a.Override<VariantGear>(nameof(VariantGear.Code), "big")
});
}));
}))!;
Assert.That(refused.Message, Does.Contain(BigKey.Value).And.Contain(BaseKey.Value).And.Contain("x"));
}