diff --git a/crates/weksa/src/store.rs b/crates/weksa/src/store.rs index 56fcc5b..9c95e70 100644 --- a/crates/weksa/src/store.rs +++ b/crates/weksa/src/store.rs @@ -344,6 +344,9 @@ impl CorpusStore { if let Some(why) = empty_attestation(&item.source) { return Err(malformed(&item.id, why)); } + if let Some(by) = &item.names_by { + check_annotator(&item.id, by)?; + } check_entities(&item, entities)?; for held in self.all()? { if normalized(&held.text) == text && item.supersedes.as_deref() != Some(&held.id) { diff --git a/crates/weksa/tests/entities.rs b/crates/weksa/tests/entities.rs index 03d139d..9d316bf 100644 --- a/crates/weksa/tests/entities.rs +++ b/crates/weksa/tests/entities.rs @@ -573,3 +573,25 @@ fn committed_items_read_with_no_names_label() { assert!(items.iter().all(|i| i.names_by.is_none()), "{sub}"); } } + +#[test] +fn a_blank_names_by_generator_is_refused_by_the_corpus_door() { + use weksa::Annotator; + use weksa::corpus::ModelFamily; + let d = tempfile::tempdir().unwrap(); + let mut entities = EntityStore::open(&d.path().join("e.cc")).unwrap(); + let mut corpus = CorpusStore::open(&d.path().join("c.cc")).unwrap(); + let blank = Annotator::Model { family: ModelFamily::Anthropic, generator: " ".into() }; + let (cast, items) = weksa::encode::WorkDraft::parse(LANTERN) + .unwrap() + .into_import(&[marked(3, "Quiet, both of you.")], &blank) + .unwrap(); + for e in cast { + entities.put(e).unwrap(); + } + assert!(matches!( + refusal(corpus.add(items[0].clone(), &entities)), + StoreRefusal::Malformed { .. } + )); + assert!(corpus.all().unwrap().is_empty()); +}