From 05a6726738c8fc3fb843964e18ff7f7005938a62 Mon Sep 17 00:00:00 2001 From: Eureka Date: Wed, 11 Nov 2026 00:14:55 +0000 Subject: [PATCH] Tests kill three open_direct mutants: schema field description, non-UnknownKind refusal, payload-persona mismatch Co-Authored-By: Claude Sonnet 5.5 --- crates/mind-body/src/persona/tests.rs | 6 ++++-- crates/mind-body/tests/chat_rudp.rs | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/mind-body/src/persona/tests.rs b/crates/mind-body/src/persona/tests.rs index 11d61e3..19e42f0 100644 --- a/crates/mind-body/src/persona/tests.rs +++ b/crates/mind-body/src/persona/tests.rs @@ -7845,8 +7845,10 @@ fn an_open_the_mouth_does_not_serve_is_told_as_not_sent() { fn the_daily_creation_policy_has_one_text_in_the_schema_and_the_notice() { let schema = reply_schema(&["swarm".to_string()], &[], true); let told = open_told("@ann:chat", Some(DirectOutcome::DailyLimit)); - assert!(open_direct_description().contains(OPEN_DAILY_POLICY) && told.contains(OPEN_DAILY_POLICY), "{told}"); - assert!(schema.contains(OPEN_DAILY_POLICY)); + assert!(told.contains(OPEN_DAILY_POLICY), "{told}"); + let schema: Value = serde_json::from_str(&schema).unwrap(); + let described = schema.pointer("/properties/open_direct/anyOf/1/description").and_then(Value::as_str).unwrap_or_default(); + assert!(described.contains(OPEN_DAILY_POLICY), "{described}"); } #[test] diff --git a/crates/mind-body/tests/chat_rudp.rs b/crates/mind-body/tests/chat_rudp.rs index 530e85e..927062f 100644 --- a/crates/mind-body/tests/chat_rudp.rs +++ b/crates/mind-body/tests/chat_rudp.rs @@ -13,7 +13,7 @@ use std::thread::JoinHandle; use std::time::Duration; use cultnet_rs::{CultNetMessage, CultNetRawDocumentRecord, CultNetRawPayloadEncoding, CultNetRudpSocketTransportConnection, CultNetRudpSocketTransportOptions}; -use mind_body::chat_client::{self, MouthRefused, Refusal, REFUSAL, ACK, Chat, ChatAck, ChatOpenDirectReceipt, ChatOpenDirectRequest, DirectOutcome, OPEN_DIRECT_RECEIPT, OPEN_DIRECT_REQUEST, ChatPending, ChatPendingRequest, ChatRead, ChatSendReceipt, ChatSendRequest, PENDING, PENDING_REQUEST, PENDING_V1, READ, SEND_RECEIPT, SEND_REQUEST}; +use mind_body::chat_client::{self, ChatRefusal, MouthRefused, Refusal, REFUSAL, ACK, Chat, ChatAck, ChatOpenDirectReceipt, ChatOpenDirectRequest, DirectOutcome, OPEN_DIRECT_RECEIPT, OPEN_DIRECT_REQUEST, ChatPending, ChatPendingRequest, ChatRead, ChatSendReceipt, ChatSendRequest, PENDING, PENDING_REQUEST, PENDING_V1, READ, SEND_RECEIPT, SEND_REQUEST}; use mind_body::chat_rudp::{RudpChat, connection_id}; const ACK_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v1/gamecult.persona.chat_ack.v1.msgpack"); @@ -24,6 +24,7 @@ const SEND_RECEIPT_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v2/gamec const SEND_REQUEST_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v2/gamecult.persona.chat_send_request.v2.nil-basis.msgpack"); const OPEN_REQUEST_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v4/gamecult.persona.chat_open_direct_request.v1.msgpack"); const UNKNOWN_KIND_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v4/gamecult.persona.chat_refusal.v1.unknown-kind.msgpack"); +const REFUSAL_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v1/gamecult.persona.chat_refusal.v1.msgpack"); const OPENED_BYTES: &[u8] = include_bytes!("fixtures/persona-chat-v4/gamecult.persona.chat_open_direct_receipt.v1.opened.msgpack"); const KEY: &str = "connection-key-for-test"; @@ -262,3 +263,24 @@ fn a_refusal_for_another_persona_or_another_kind_does_not_satisfy_the_open() { let error = client(&wrong_kind, KEY, "eureka", Duration::from_millis(800)).open_direct(&request).unwrap_err(); assert!(error.downcast_ref::().is_none(), "another kind is not heard: {error}"); } + +#[test] +fn a_refusal_of_another_kind_ends_the_wait_but_is_not_told_as_not_sent() { + // The fixture refusal is persona "ghost", UnknownPersona: the mouth refuses this Persona's open for a reason other than the kind. + let mouth = opening_with((REFUSAL, Some("ghost"), REFUSAL_BYTES)); + let request = chat_client::decode::(OPEN_REQUEST_BYTES).unwrap(); + let started = std::time::Instant::now(); + let error = client(&mouth, KEY, "ghost", Duration::from_secs(20)).open_direct(&request).unwrap_err(); + assert!(started.elapsed() < Duration::from_secs(5), "the refusal ends the wait: {:?}", started.elapsed()); + assert!(error.downcast_ref::().is_none(), "only UnknownKind is a known not-sent: {error}"); + assert!(error.to_string().contains("UnknownPersona"), "{error}"); +} + +#[test] +fn an_unknown_kind_refusal_keyed_by_this_persona_but_naming_another_is_not_heard_as_not_sent() { + let other = chat_client::encode(&ChatRefusal { persona: "someone-else".into(), refusal: Refusal::UnknownKind }).unwrap(); + let mouth = opening_with((REFUSAL, Some("eureka"), Box::leak(other.into_boxed_slice()))); + let request = chat_client::decode::(OPEN_REQUEST_BYTES).unwrap(); + let error = client(&mouth, KEY, "eureka", Duration::from_secs(20)).open_direct(&request).unwrap_err(); + assert!(error.downcast_ref::().is_none(), "the payload names another Persona: {error}"); +}