cultcache-rs: pin delete's retype and foreign refusals to the put's conflict
All checks were successful
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 18m52s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-17 02:08:04 +00:00
commit 60ff1df14d

View file

@ -574,14 +574,33 @@ fn a_store_attached_after_a_refused_load_keeps_the_refusal_reason() {
assert!(refused.reason.contains("bytes after"), "refusal reason lost: {}", refused.reason);
}
// A key held by another registered type: put, is_writable and typed delete all refuse (delete used to answer Ok(false)).
// A key held by another registered type, or carried as a foreign record: put, is_writable and typed delete all refuse, and
// delete refuses with the put's conflict (delete used to answer Ok(false)). This agreement is for those two cases; for a
// type with no home store delete's home-store error comes before the retype judge, and both still refuse.
#[test]
fn delete_of_a_key_held_by_another_registered_type_is_refused_like_the_put() {
let (mut cache, _dir, _path) = held_marked_and_clean();
assert!(!cache.is_writable(SlotUnit::TYPE, "clean").unwrap());
let put = cache.put("clean", &SlotUnit { name: "n".into(), outcome: UnitOutcome::Denied });
assert!(put.is_err());
let error = cache.delete::<SlotUnit>("clean").unwrap_err();
assert!(!format!("{error:#}").is_empty());
let put = cache.put("clean", &SlotUnit { name: "n".into(), outcome: UnitOutcome::Denied }).unwrap_err();
let delete = cache.delete::<SlotUnit>("clean").unwrap_err();
let (put, delete) = (conflict(&put), conflict(&delete));
assert_eq!(delete.record_key, "clean");
assert_eq!(delete.record_key, put.record_key);
assert_eq!(delete.schema_names, put.schema_names);
assert!(delete.schema_names.contains(&UnionSurface::TYPE.to_string()), "{:?}", delete.schema_names);
assert!(cache.snapshot_envelopes().iter().any(|held| held.key == "clean" && held.r#type == UnionSurface::TYPE));
// A foreign record at the key: only UnionSurface registered, the store's unit-arm record is foreign here.
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("extra-slot-store.cc");
std::fs::write(&path, without_variant_row(&vector("extra-slot-store.cc"))).unwrap();
let mut cache = CultCache::new();
cache.register_entry_type::<UnionSurface>().unwrap();
cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&path)).unwrap();
cache.pull_all_backing_stores().unwrap();
assert!(!cache.is_writable(UnionSurface::TYPE, "unit-arm").unwrap());
let put = cache.put("unit-arm", &constructed()).unwrap_err();
let delete = cache.delete::<UnionSurface>("unit-arm").unwrap_err();
assert_eq!(conflict(&delete).record_key, "unit-arm");
assert_eq!(conflict(&delete).schema_names, conflict(&put).schema_names);
}