Tests: the recovery tests assert the refusal

Rust, TypeScript and Python each had a test that a record missing its catalog entry is recovered from its payload; each now asserts
the store is unreadable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 05:58:47 +02:00
commit ed61462a70
3 changed files with 11 additions and 29 deletions

View file

@ -186,7 +186,7 @@ class CultCacheTests(unittest.TestCase):
self.assertEqual(raw[2][0][0], "app")
self.assertEqual(raw[2][0][1], "settings")
def test_messagepack_store_recovers_schema_stamped_record_missing_catalog_entry(self) -> None:
def test_messagepack_store_refuses_a_record_whose_schema_the_catalog_does_not_publish(self) -> None:
try:
import msgpack # type: ignore
except ModuleNotFoundError:
@ -227,11 +227,9 @@ class CultCacheTests(unittest.TestCase):
.build()
)
cache.pull_all_backing_stores()
self.assertEqual(cache.get_required(document, "record-1")["value"], "still readable")
envelope = cache.get_required_envelope(document, "record-1")
self.assertEqual(envelope.type, "runtime-policy")
self.assertEqual(envelope.schema_id, "sha256:stale-schema-id-from-cold-record")
# The payload opens with a schema version, and the catalog is the store's own description: no recovery.
with self.assertRaises(StoreUnreadableError):
cache.pull_all_backing_stores()
def test_interop_cli_helpers_round_trip_v1_store(self) -> None:
with tempfile.TemporaryDirectory() as tmp:

View file

@ -4379,7 +4379,7 @@ mod tests {
}
#[test]
fn messagepack_store_recovers_schema_stamped_records_missing_catalog_entries() -> Result<()> {
fn messagepack_store_refuses_a_record_whose_schema_the_catalog_does_not_publish() -> Result<()> {
let temp = tempfile::tempdir()?;
let store_path = temp.path().join("missing-catalog.msgpack");
let expected = SchemaStamped {
@ -4387,8 +4387,7 @@ mod tests {
name: "schema-stamped".to_string(),
value: "still readable".to_string(),
};
// An empty catalog with a stale schema id is what a record written by
// another runtime, or one older than its catalog, looks like on disk.
// An empty catalog with a stale schema id.
let snapshot = PersistedStoreSnapshot(
"cultcache.store.v1".to_string(),
Vec::new(),
@ -4404,15 +4403,9 @@ mod tests {
let mut cache = CultCache::new();
cache.register_entry_type::<SchemaStamped>()?;
cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&store_path))?;
cache.pull_all_backing_stores()?;
assert_eq!(cache.get_required::<SchemaStamped>("record-1")?, expected);
assert_eq!(
cache
.get_required_envelope::<SchemaStamped>("record-1")?
.schema_id,
Some("sha256:stale-schema-id-from-cold-record".to_string())
);
// The payload opens with a schema version, and the catalog is the store's own description: no recovery.
let error = cache.pull_all_backing_stores().unwrap_err();
assert!(error.downcast_ref::<StoreUnreadableError>().is_some(), "{error:#}");
Ok(())
}

View file

@ -441,7 +441,7 @@ test("SingleFileMessagePackBackingStore reads CultCache v1 snapshots by schema i
assert.equal(cache.getRequiredEnvelope(noteDocument, "record-1").schemaId, "schema-1");
});
test("SingleFileMessagePackBackingStore recovers schema-stamped records missing catalog entries", async () => {
test("SingleFileMessagePackBackingStore refuses a record whose schema the catalog does not publish, whatever its payload opens with", async () => {
const stampedDocument = defineDocumentType({
type: "runtime-policy",
schema: z.tuple([
@ -481,16 +481,7 @@ test("SingleFileMessagePackBackingStore recovers schema-stamped records missing
.withGenericStore(new SingleFileMessagePackBackingStore(storePath))
.build();
await cache.pullAllBackingStores();
assert.deepEqual(cache.getRequired(stampedDocument, "record-1"), [
"tests.schema_stamped_entry.v1",
"schema-stamped",
"still readable",
]);
assert.equal(
cache.getRequiredEnvelope(stampedDocument, "record-1").schemaId,
"sha256:stale-schema-id-from-cold-record",
);
await assert.rejects(() => cache.pullAllBackingStores(), StoreUnreadableError);
});
test("SingleFileMessagePackBackingStore heals legacy envelopes whose payload was persisted as an object", async () => {