Contract: the apply checks ownership by declaration again where the write lands; declaring an id makes it writable under the writing type's id
The persistence contract's rule 3 now says the store refuses, under its lock, a write or removal at a key whose durable record is under an undeclared id, for the store's own write API and for CultMesh single-file writes, which declare through the catalog entry they write. The sentence that a declaring type stores the record under its own id is corrected: Declares is registry-wide, so the record lands under the writing type's id. The late-registration test is renamed to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
51fbe6f533
commit
463abc5c7c
3 changed files with 16 additions and 4 deletions
|
|
@ -192,8 +192,15 @@ therefore opens in every runtime that holds the id.
|
|||
under any other id that a type can read, through the catalog's schema name or an entry listing a
|
||||
local id, is loaded read-only: Get and queries serve it, a write of another record copies it as
|
||||
stored, and a staged write or removal of it (upsert, variant upsert, flatten, remove, commit) is
|
||||
refused with the typed schema conflict before anything is staged. Declaring its id compatible on a
|
||||
type claims it: the next write stores it under that type's own id.
|
||||
refused with the typed schema conflict before anything is staged. Declaring its id compatible on any
|
||||
registered type makes it writable: the next write stores it under the writing type's own id.
|
||||
|
||||
The rule is checked again where the write lands, under the store's lock: a write or removal at a key
|
||||
whose durable record is under an undeclared id, because another writer rewrote it after this cache
|
||||
loaded, is refused typed, and the record is reloaded as the store holds it, read-only when a type can
|
||||
read it. This holds for every write through the store, the store's own `Push`, `Delete` and
|
||||
`CommitBatch` included. A CultMesh single-file write declares the ids of the catalog entry it writes,
|
||||
its own and those it lists compatible, and is refused the same way.
|
||||
|
||||
A record that resolves to no local type is a foreign record, for example one of a type this build does not
|
||||
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
|
||||
|
|
|
|||
|
|
@ -258,6 +258,11 @@ refuses to replace a file whose header it cannot read, and leaves it as it was.
|
|||
- A single-file store and a directory store apply this cache's staged writes and
|
||||
removals onto what the store holds now: another writer's unrelated records
|
||||
survive as stored, a key both wrote holds the last write.
|
||||
- In both store kinds, a write or removal at a key whose durable record is under
|
||||
an id the writer does not declare is refused with the typed schema conflict
|
||||
before anything is written, and that record is reloaded as the store holds
|
||||
it: dropped when foreign, held read-only when a type reads it
|
||||
(cultcache-persistence-format.md, ownership by declaration).
|
||||
- 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
|
||||
|
|
|
|||
|
|
@ -794,9 +794,9 @@ namespace GameCult.Caching.Tests
|
|||
}
|
||||
|
||||
// Whether a record is read-only is read live from the registry at the write, not fixed at load: a type registered after the
|
||||
// load that declares the id claims the record.
|
||||
// load that declares the id makes the record writable, and the write stores it under the writing type's id, not the declarer's.
|
||||
[Test]
|
||||
public void ATypeRegisteredAfterLoadThatDeclaresTheIdClaimsIt()
|
||||
public void ATypeRegisteredAfterLoadThatDeclaresTheIdMakesItWritable()
|
||||
{
|
||||
var path = OtherRuntimeStore("late.cc");
|
||||
var registry = CultDocumentRegistry.ForTypes(new[] { Deck });
|
||||
|
|
|
|||
Loading…
Reference in a new issue