Pin V18: validate cases and the encoder-shaped request through admit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5622e825b2
commit
fb96348d02
2 changed files with 82 additions and 0 deletions
|
|
@ -593,6 +593,41 @@ mod lowering {
|
|||
assert!(Prompt::lower(&read, &item, &away(), "en-US", &inv, &held, &empty).is_ok());
|
||||
}
|
||||
|
||||
/// The packet the encoder emits for a request: frame:3, no consent, source
|
||||
/// ModelDecomposition. Admission refuses it, so no lowering view exists.
|
||||
#[test]
|
||||
fn an_encoder_request_never_reaches_a_lowerer() {
|
||||
let cast = InventoryStore::open(&data("interlingua/inventory.cc")).unwrap();
|
||||
let entities = EntityStore::open(&data("entity/entity.cc")).unwrap();
|
||||
let corpus = CorpusStore::open(&data("corpus/corpus.cc")).unwrap();
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut store = PacketStore::open(&dir.path().join("p.cc")).unwrap();
|
||||
let mut packet = proof_packet();
|
||||
packet.provenance.source = weksa::packet::ProvenanceSource::ModelDecomposition;
|
||||
packet.predications[0].frame = weksa::InvId::parse("frame:3").unwrap();
|
||||
match store.admit(packet.clone(), &cast, &corpus, &entities) {
|
||||
Err(weksa::StoreError::Invalid(r)) => assert_eq!(
|
||||
r,
|
||||
vec![weksa::Refusal::V18RequestWithoutConsent {
|
||||
predication: weksa::packet::NodeId::parse("n4").unwrap()
|
||||
}]
|
||||
),
|
||||
other => panic!("expected V18, got {:?}", other.map(|_| ())),
|
||||
}
|
||||
// Not blanket: telemetry that records the consent admits and lowers.
|
||||
packet.provenance.source = weksa::packet::ProvenanceSource::GameTelemetry;
|
||||
packet.discourse.addressee_consent = Some(weksa::packet::NodeId::parse("n4").unwrap());
|
||||
drop(store);
|
||||
let view = admitted(packet, &cast, "corpus/corpus.cc", &entities);
|
||||
let item = CorpusItemId::parse("item:nibu:1").unwrap();
|
||||
let held = Held(vec![nibu(&[("en-US", &["Nibu"])])]);
|
||||
let empty = weksa::Ontology::empty();
|
||||
assert!(
|
||||
Prompt::lower(&view, &item, &away(), "en-US", &cast.inventory().unwrap(), &held, &empty)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
fn dao(index: usize) -> (LoweringInput, Inventory, EntityStore, CorpusItemId) {
|
||||
let inv = InventoryStore::open(&data("daodejing/inventory.cc")).unwrap();
|
||||
let entities = EntityStore::open(&data("daodejing/entity.cc")).unwrap();
|
||||
|
|
|
|||
|
|
@ -740,6 +740,53 @@ fn a_source_that_only_read_wording_cannot_set_consent() {
|
|||
}
|
||||
}
|
||||
|
||||
// V18: a request frame is licensed by the packet's own consent record.
|
||||
|
||||
/// The committed inventory, where `frame:3` is `request_intervention`.
|
||||
fn cast_refusals(p: &Packet) -> Vec<Refusal> {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../data/interlingua/inventory.cc");
|
||||
let inv = weksa::InventoryStore::open(&path).unwrap().inventory().unwrap();
|
||||
validate(p, &inv).err().unwrap_or_default()
|
||||
}
|
||||
|
||||
fn requesting() -> Packet {
|
||||
let mut p = proof_packet();
|
||||
p.predications[0].frame = iv("frame:3");
|
||||
p.discourse.addressee_consent = Some(nd("n4"));
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_request_frame_needs_consent_naming_its_predication() {
|
||||
assert_eq!(cast_refusals(&requesting()), vec![]);
|
||||
let mut p = requesting();
|
||||
p.discourse.addressee_consent = None;
|
||||
assert_eq!(
|
||||
cast_refusals(&p),
|
||||
vec![Refusal::V18RequestWithoutConsent { predication: nd("n4") }]
|
||||
);
|
||||
p.discourse.addressee_consent = Some(nd("n5"));
|
||||
assert_eq!(
|
||||
cast_refusals(&p),
|
||||
vec![Refusal::V18RequestWithoutConsent { predication: nd("n4") }]
|
||||
);
|
||||
let mut p = requesting();
|
||||
p.provenance.source = ProvenanceSource::GameTelemetry;
|
||||
assert_eq!(cast_refusals(&p), vec![]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_source_consent_is_v15_alone() {
|
||||
let mut p = requesting();
|
||||
p.provenance.source = ProvenanceSource::ModelDecomposition;
|
||||
assert_eq!(
|
||||
cast_refusals(&p),
|
||||
vec![Refusal::V15ConsentSource {
|
||||
source: ProvenanceSource::ModelDecomposition
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
// V17: the addressee is someone spoken to, a referent.
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue