Contracts: every writable store judges a batch's checks; a store kind lists foreign records at the version it read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-14 02:07:21 +02:00
commit 7be966b485
2 changed files with 6 additions and 3 deletions

View file

@ -206,7 +206,7 @@ A record that resolves to no local type is a foreign record, for example one of
have, or one renamed under a new schema name without declaring its old id. A store never destroys or relabels it: the store carries it
byte for byte under its own id and its own catalog entry, lists it as foreign (`CacheBackingStore.ForeignRecords`
in C#), and the cache never holds it. Writes of other records proceed and copy it forward as the file holds it. A write that would replace or remove it is refused with the typed schema conflict
naming its key and id, and nothing is written. A removal of a key the cache does not hold removes nothing and is free; the store judges the key at its next flush or commit, under its lock, with the keys that write writes, and refuses the write if it holds a record there under an undeclared id, also when that record arrived after the load. A judged key is never removed. A read-only store answers at the removal, from its last load. The refused keys are reloaded as the store holds them (a foreign record is not held, and is listed as foreign from then on, so its next write is refused before staging), and their staged changes are forgotten. A write that carries a record forward keeps a marked header marked. Declaring its id on a type claims it at the next load.
naming its key and id, and nothing is written. A removal of a key the cache does not hold removes nothing and is free; the store judges the key at its next flush or commit, under its lock, with the keys that write writes, and refuses the write if it holds a record there under an undeclared id, also when that record arrived after the load. A commit judges such a key in every writable store its cache attaches, each under its own lock: the stores it does not write first, then the store it writes, and a refusal in any of them writes nothing. A judged key is never removed. A read-only store answers at the removal, from its last load. The refused keys are reloaded as the store holds them (a foreign record is not held, and is listed as foreign from then on, so its next write is refused before staging), and their staged changes are forgotten. A write that carries a record forward keeps a marked header marked. Declaring its id on a type claims it at the next load.
A reader resolves a record's schema id to the entry that owns it, that entry's own `schemaId`, and
only when no entry owns the id to an entry that lists it as a compatible id (the first such entry

View file

@ -265,9 +265,12 @@ refuses to replace a file whose header it cannot read, and leaves it as it was.
(cultcache-persistence-format.md, ownership by declaration).
- A removal of a key the cache does not hold travels as a check-only key: a
commit carries it in the request, a flush stages it, and either store kind
judges it under its lock with the keys it writes, never removing it. A batch
judges it under its lock with the keys it writes, never removing it. Every
writable store judges a batch's checks under its own lock: the stores the
batch does not commit through first (`JudgeChecks`), the home last. A batch
that only checks keys writes no file. `ExpectUnchanged` compares the foreign
records a store carries at the versions it read them.
records a store carries at the versions it read them; a store kind lists a
foreign record through `Foreign` with the version it read.
- A single-file store holding a variant (the directory store refuses variants)
is written only from what its writer last read. A record that moved refuses
the whole write with the typed write conflict, and the refused and moved keys