Apply refusal: a write over a durable record under an undeclared id is refused at ApplyWriteSet and reloads read-only

ForeignOnDisk and the two RefuseForeign calls in PushAll and CommitBatchCore are
gone. ApplyWriteSet refuses first, over every key it writes or removes, by
Registry.Declares for a cache and by the catalog entry it writes for a cacheless
CultMesh write. Both refusals reload through one DurableAt; the directory store
reloads through LoadPage, the per-record body of LoadRecordPages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-03 13:08:44 +02:00
commit 067df993a3
4 changed files with 123 additions and 66 deletions

View file

@ -17,6 +17,8 @@ public sealed class CultMeshSingleFileElementIdTests
{
private const string HexA = "aaaaaaaaaaaa";
private static readonly CultRecordKey Key = new("publication");
// A raw write lands beside the typed record, never over it: neither declares the other's schema id.
private static readonly CultRecordKey RawKey = new("raw");
private string _root = null!;
@ -84,12 +86,12 @@ public sealed class CultMeshSingleFileElementIdTests
var schema = new CultMeshSingleFileDocumentSchema("raw:schema", "RawSchema", "1");
var payload = new byte[] { 0x90 };
CultMesh.WriteSingleFileDocumentPayload(path, Key, schema, null, payload);
CultMesh.WriteSingleFileDocumentPayload(path, RawKey, schema, null, payload);
HeaderOf(path).Should().Be("cultcache.store.v1");
CultMesh.WriteSingleFileDocument(path, Key, Publication(Descriptor()));
HeaderOf(path).Should().Be("cultcache.store.v3");
CultMesh.WriteSingleFileDocumentPayload(path, Key, schema, null, payload);
CultMesh.WriteSingleFileDocumentPayload(path, RawKey, schema, null, payload);
HeaderOf(path).Should().Be("cultcache.store.v3", "the payload's ids are not the writer's to see");
}
@ -102,7 +104,7 @@ public sealed class CultMeshSingleFileElementIdTests
var marked = Path_("marked.cc");
CultMesh.WriteSingleFileDocument(marked, Key, Publication(Descriptor()));
CultMesh.WriteSingleFileDocumentPayload(marked, Key, schema, null, new byte[] { 0x90 });
CultMesh.WriteSingleFileDocumentPayload(marked, RawKey, schema, null, new byte[] { 0x90 });
HeaderOf(marked).Should().Be("cultcache.store.v3", "a whole marked file is still written and stays marked");
}