Contracts: extra slots are read-only, not ignored

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-10 14:35:10 +00:00 • committed by Libby
commit 53d2f11780
2 changed files with 20 additions and 4 deletions

View file

@ -202,6 +202,12 @@ flatten, remove, commit) is refused with the typed schema conflict before anythi
Declaring its id compatible on any registered type makes it writable and is the consent to the loss:
the next write stores it under the writing type's own id and sheds the slots.
A record whose payload carries a slot past the slots its reader declares, at any depth (nested object, list
element, union arm, unit arm), is read-only the same way, whatever id it is stored under. The one consent
is the declaration above, and it reaches only depth-0 slots the schema comparison reports ignored under a
listed compatible id: a mark anywhere else, or at depth 0 under the reader's own id, is not consented to.
`CultCache.IsWritable(key)` answers the same question the staging refusal asks.
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 not owned, 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
@ -535,15 +541,14 @@ Read directly when:
Allowed when:
- persisted schema has missing slots that the local schema can default
- persisted schema has extra slots the local reader can safely ignore or preserve
- slot meanings remain compatible
Soft migration should emit warnings, not silent shrugs.
A persisted schema with extra slots the local reader lacks is not soft: the record is read-only (see the ownership
rule above). Soft migration should emit warnings, not silent shrugs.
Typical warnings:
- missing slot defaulted
- unknown extra slot ignored
- nullable/default behavior widened
- field preserved but not surfaced natively

View file

@ -107,10 +107,21 @@ persisted slots honestly:
- persisted schema id differs, but the embedded catalog points to a compatible
local schema id
- persisted slot is missing locally and can be ignored
- persisted slot is missing locally and the record is read-only until its id is declared compatible
(see Extra slots are read-only, below)
- local slot is missing in persisted data and can fall back to the local
default value
Extra slots are read-only. A record whose payload carries a slot past the slots its reader declares, at any
depth (the record, a nested object, a list element, a union arm, a unit arm), is loaded read-only: it is
served, `CultStoredDocument.UnreadSlots` names the first type read with extra slots and both counts, and
`CultCache.IsWritable(key)` is false. A staged write or removal of it is refused with
`CultSchemaConflictException` (`UnreadSlots` set; the message names the type and the counts, never a slot
value). A missing trailing slot keeps its default and stays writable; a non-nil value in a retired gap below
the highest key is not extra. Declaring an id compatible consents only to depth-0 slots the schema comparison
reports ignored under that id; any other mark (nested, list element, arm, unit arm, or depth 0 under the
reader's own id) keeps the record read-only whatever is declared.
The cache emits a typed migration report with:
- exact vs compatible-drift classification