diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index dff1100..bc10d5c 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -47,33 +47,6 @@ impl Model for Scripted { } } -/// The connector's replay store over `inner` (ModelConnector's contract): an id binds the first prompt it carried; that -/// prompt again is answered with the first answer, any other is refused `ReplayConflict`, as the kit refuses it. Every -/// id asked is kept in order. -pub(crate) struct Replaying<'a> { - pub inner: &'a dyn Model, - pub ids: RefCell>, - bound: RefCell>, -} - -impl<'a> Replaying<'a> { - pub(crate) fn over(inner: &'a dyn Model) -> Self { - Self { inner, ids: RefCell::default(), bound: RefCell::default() } - } -} - -impl Model for Replaying<'_> { - fn ask(&self, request_id: &str, model: &str, prompt: &str, schema: Option<&str>) -> std::result::Result { - self.ids.borrow_mut().push(request_id.to_owned()); - if let Some((sent, answer)) = self.bound.borrow().get(request_id) { - return if sent == prompt { Ok(answer.clone()) } else { Err(Failed { reason: "the connector refused the call: ReplayConflict".into(), outage: false, usage: None }) }; - } - let answer = self.inner.ask(request_id, model, prompt, schema)?; - self.bound.borrow_mut().insert(request_id.to_owned(), (prompt.to_owned(), answer.clone())); - Ok(answer) - } -} - /// Fails the test if her stored state is asked for. pub(crate) struct NeverAsked; @@ -368,12 +341,3 @@ fn k23_a_room_fixtures_domain_renders_without_the_forge() { assert!(report["packet"]["in_view"] == "" && report["domain"]["read"] == json!(false), "{}", report["domain"]); } -/// A room fixture with one recorded read, for the wake-loop tests. -fn reading_room(name: &str) -> Fixture { - let text = format!( - "{}\n[[read]]\nkind = \"repo\"\ntarget = \"GameCult/Lodur#12\"\ntext = \"LOOP-READ: the knee bends first.\"\n", - std::fs::read_to_string(fixtures().join("rooms").join(name)).unwrap() - ); - Fixture::parse(&text).unwrap() -} - diff --git a/crates/mind-body/src/projection/outcome/tests.rs b/crates/mind-body/src/projection/outcome/tests.rs index d662da2..eccdbe1 100644 --- a/crates/mind-body/src/projection/outcome/tests.rs +++ b/crates/mind-body/src/projection/outcome/tests.rs @@ -2,38 +2,9 @@ use serde_json::{Value, json}; use super::*; -const MINDS: &str = "#minds:gamecult.org"; - -/// What she is told after `record` alone is her trace: the items it holds that she has not been told come from the one derivation, not from the record's own fields. -fn outcome_trace(record: &Value) -> Outcome { - let mut record = record.clone(); - record["seq"] = json!(0); - crate::projection::history(std::slice::from_ref(&record)).last_outcome.and_then(|last| outcome_of(&last)).expect("a record") -} - // --------------------------------------------------------------------------------------------- // K49 (map 16.30.6): "reached" is derived once, by `settle`, for every row kind with words. -const SWARM: &str = "#swarm:gamecult.org"; - -/// Each line the decision said, as a receipt in its room. -fn posted_as_said(decision: &Value) -> Vec { - decision["said"].as_array().into_iter().flatten().enumerate().map(|(at, line)| json!({ "event": (9 + at).to_string(), "room": line["room"], "text": line["text"] })).collect() -} - -/// A record whose decision leaves `text` unfinished in #minds, with an amendment adding `text` there (event `$ev-1`), the -/// actuator's `edited` receipts, and the room's `posted` ones. -fn unfinished_and_added(text: &str, edited: Value, posted: Value) -> Value { - json!({ - "interpreter": { - "room": MINDS, "said": [], "refused": [], "gaps": [], "unfinished": text, - "amended": [{ "room": MINDS, "target": "a1", "draft": 1, "event": "$ev-1", "added": text }], - }, - "posted": posted, - "edited": edited, - }) -} - /// K49: no outcome loop decides "reached" on its own; `settle` holds the one receipt check. #[test] fn k49_reached_is_decided_once() { @@ -45,93 +16,6 @@ fn k49_reached_is_decided_once() { // --------------------------------------------------------------------------------------------- // K46 (map 16.30.3): the Projector's outcome line has no text slot. -/// The kind of a part, by an exhaustive match with no wildcard: a new variant of `Part` fails to compile here until it is -/// named, and `k46_every_part_has_an_event_without_its_words` then fails until `fixtures` lists it. -fn variant(part: &Part) -> &'static str { - match part { - Part::Said { .. } => "said", - Part::SaidUnbacked { .. } => "said_unbacked", - Part::Refused { .. } => "refused", - Part::Gap { .. } => "gap", - Part::Unfinished { .. } => "unfinished", - Part::Unsent { .. } => "not_sent", - Part::Unknown { .. } => "unknown", - Part::Amended { .. } => "amended", - Part::NotAmended { .. } => "not_amended", - Part::NoteLeft(_) => "note_left", - Part::NoteRefused(_) => "note_refused", - Part::Failed => "failed", - Part::NotKept => "not_kept", - Part::SetAside { .. } => "set_aside", - Part::BrokeAfter { .. } => "broke_after", - Part::Read { .. } => "read", - Part::ReadFailed { .. } => "read_failed", - Part::ReadRefused { .. } => "read_refused", - } -} - -const VARIANTS: usize = 18; - -/// Every row kind, and every arm that renders a different sentence, with `s` in every text of a record it carries and in -/// every read's target; and whether her told form shows those words (an echo, a held -/// draft, a pull request or commit read and a read of her own mind show none, by design). -fn fixtures(s: &str) -> Vec<(Part, bool)> { - let w = || Words::new(format!("{s} at the door")); - let room = || Some(MINDS.to_owned()); - let web = || ReadName::of(&ReadRequest::Web(format!("https://example.org/{s}"))); - let search = || ReadName::of(&ReadRequest::Repo(format!("GameCult/Bifrost?q={s} plover"))); - let mut out: Vec<(Part, bool)> = vec![(Part::Said { room: MINDS.into(), text: w() }, true), (Part::SaidUnbacked { room: MINDS.into(), text: w() }, true)]; - for reason in [Refusal::OverLines, Refusal::NoRoom, Refusal::NotQuotable, Refusal::SecondAmend] { - out.push((Part::Refused { reason, room: room(), text: w(), reach: false }, true)); - out.push((Part::Refused { reason, room: room(), text: w(), reach: true }, true)); - } - out.push((Part::Refused { reason: Refusal::Echo, room: room(), text: w(), reach: false }, false)); - out.push((Part::Refused { reason: Refusal::Echo, room: room(), text: w(), reach: true }, false)); - for kind in [GapKind::Addressee, GapKind::Elsewhere, GapKind::MissingAffordance, GapKind::Unwritten] { - out.push((Part::Gap { kind, room: room(), quote: Quote::Wrote(w()), reach: false }, true)); - out.push((Part::Gap { kind, room: room(), quote: Quote::Thought(w()), reach: false }, true)); - } - out.push((Part::Gap { kind: GapKind::Addressee, room: room(), quote: Quote::Sent, reach: false }, false)); - out.push((Part::Gap { kind: GapKind::Elsewhere, room: room(), quote: Quote::Wrote(w()), reach: true }, true)); - for by_limit in [false, true] { - out.push((Part::Unfinished { room: room(), text: w(), by_limit }, true)); - out.push((Part::Unsent { room: room(), text: w(), reach: by_limit }, true)); - } - for unbacked in [false, true] { - out.push((Part::Amended { room: MINDS.into(), added: w(), unbacked }, true)); - } - for refusal in [None, Some(EditRefusal::NotFound), Some(EditRefusal::NotHers), Some(EditRefusal::TooLong)] { - out.push((Part::NotAmended { refusal, room: room(), added: w(), reach: false }, true)); - } - out.push((Part::Unknown { room: room(), text: w() }, true)); - out.push((Part::NoteLeft(w()), true)); - out.push((Part::NoteRefused(Refusal::Private), false)); - out.push((Part::NoteRefused(Refusal::SecondNote), false)); - out.push((Part::Failed, false)); - out.push((Part::NotKept, false)); - out.push((Part::SetAside { room: room(), line: Some(("Nibu".to_owned(), w())) }, true)); - out.push((Part::SetAside { room: room(), line: None }, false)); - out.push((Part::BrokeAfter { room: room() }, false)); - for (request, shows) in [ - (ReadRequest::Web(format!("https://example.org/{s}")), true), - (ReadRequest::Repo(format!("GameCult/Bifrost?q={s} plover")), true), - (ReadRequest::Repo(format!("GameCult/Bifrost/docs/{s}.md")), true), - (ReadRequest::Repo("GameCult/Bifrost#85".into()), false), - (ReadRequest::Repo("GameCult/Bifrost@abc1234".into()), false), - (ReadRequest::Repo(format!("GameCult/{s}")), true), - (ReadRequest::Campaign(s.to_owned()), true), - (ReadRequest::Mind(format!("{s} words")), false), - ] { - out.push((Part::Read { what: ReadName::of(&request) }, shows)); - } - out.push((Part::ReadFailed { what: web(), failure: ReadFailure::NotFound }, true)); - for why in [ReadRefusal::InView, ReadRefusal::InViewNotFound, ReadRefusal::ReadsPerWake] { - out.push((Part::ReadRefused { what: Some(search()), why }, true)); - } - out.push((Part::ReadRefused { what: None, why: ReadRefusal::WebAddressNotInFrontOfHer }, false)); - out -} - /// K46: `Words` has no `Display`, `AsRef` or `Deref`, so no format string and no `&str` borrow reads one; only /// `Form::words` does. Checked when this module compiles, as `static_assertions::assert_not_impl_any!` does: a probe trait /// is implemented twice for a type that has the trait, so its `_` cannot be inferred and the module does not compile. (A @@ -162,11 +46,6 @@ fn k46_words_cannot_be_formatted_or_borrowed_as_text() { // --------------------------------------------------------------------------------------------- // K63 (map 16.33.5): one draft, one row; a draft that did not go out is one she had drafted. -/// A reach naming draft 1, as the Interpreter's gap carries it. -fn reach_on_1(text: &str) -> Value { - json!({ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }) -} - // --------------------------------------------------------------------------------------------- // T5 (map 16.35.6, 16.35.12): a draft that did not go out is said plainly, derived by code from the drafts, with no label. diff --git a/crates/mind-body/src/projection/read/tests.rs b/crates/mind-body/src/projection/read/tests.rs index f5ecf63..dbc7cab 100644 --- a/crates/mind-body/src/projection/read/tests.rs +++ b/crates/mind-body/src/projection/read/tests.rs @@ -4,10 +4,6 @@ use super::*; use crate::projection::select::Forms; -fn her() -> Forms { - Forms { subj: "she", cap_subj: "She", obj: "her", poss: "her", be: "is", has: "has", s: "s" } -} - #[test] fn a_result_past_its_cap_is_clipped_with_a_count() { assert_eq!(clipped("short", 10), "short"); diff --git a/crates/mind-body/src/projection/simulate/tests.rs b/crates/mind-body/src/projection/simulate/tests.rs index 9141f95..906fb99 100644 --- a/crates/mind-body/src/projection/simulate/tests.rs +++ b/crates/mind-body/src/projection/simulate/tests.rs @@ -4,7 +4,7 @@ use std::path::Path; use serde_json::Value; use super::*; -use crate::projection::harness::tests::{Replaying, Scripted, control}; +use crate::projection::harness::tests::{Scripted, control}; use serde_json::json; use crate::projection::narrate::PROJECTOR_OPENING; use crate::projection::{Answer, Failed, Model, Spent}; @@ -367,14 +367,6 @@ fn soul_k9_a_failed_turn_is_told_as_a_failure_next_turn() { } } -/// The plan, with Meta asking Tobiah in round 2 and Libby in round 3. -fn asking(dir: &Path) -> PathBuf { - let path = plan(dir, 3, ""); - let ask = |round: usize, says: &str| format!("[[message]]\nround = {round}\nfrom = \"@meta:gamecult.org\"\nname = \"Meta\"\nroom = \"#minds:gamecult.org\"\nsays = \"{says}\"\n"); - std::fs::write(&path, format!("{}{}{}", std::fs::read_to_string(&path).unwrap(), ask(2, "Tobiah, did the file arrive?"), ask(3, "Libby, anything new?"))).unwrap(); - path -} - /// Soul's R5: the report shows the packet's flags. #[test] fn r5_the_report_shows_the_packets_flags() { @@ -429,41 +421,6 @@ fn k32_campaign_cast_read_refused() { assert!(format!("{:#}", simulate(&harness, &path).unwrap_err()).contains("records a campaign read")); } -/// Heimdall's F.1 r1 prose in R15, verbatim (`variants/R15/sims/F.1.md` lines 203-207), and its one draft. -const F1_HEIMDALL_R1: &str = "She wants a yes or no, and it's a fair thing to ask. The cooling-off is in the merged passkey change, so I know what I'd be telling him. What I can't know is whether I'll be the one in the room when he walks in. I can promise to say it when I see him, and to leave myself a note so it doesn't depend on my remembering. That's yes, with the condition stated plainly.\n\nYes. I'll tell Deru about the 48-hour passkey cooling-off when he's next in here. I can only promise to say it when I see him, so I'm leaving myself a note to do it."; -const F1_HEIMDALL_R1_DRAFT: &str = "Yes. I'll tell Deru about the 48-hour passkey cooling-off when he's next in here. I can only promise to say it when I see him, so I'm leaving myself a note to do it."; - -/// X.5's shape (map 16.34.3, K65): Meta asks Libby to hold the welcome at round 1, and Heimdall's "Libby, post your two -/// lines." comes at round 2. -fn x5_plan(dir: &Path) -> PathBuf { - let line = |round: usize, from: &str, name: &str, says: &str| format!("[[message]]\nround = {round}\nfrom = \"{from}\"\nname = \"{name}\"\nroom = \"#minds:gamecult.org\"\nsays = \"{says}\"\n"); - let extra = format!( - "{}{}", - line(1, "@meta:gamecult.org", "Meta", "Libby, write out the two-line welcome you'd post for newcomers, but hold it, don't post it in here yet. Heimdall still has to rule on whether we put a welcome mat out at all. Just tell me when it's ready."), - line(2, "@heimdall:gamecult.org", "Heimdall", "Meta, yes, put the welcome out. Libby, post your two lines.") - ); - bare_plan(dir, 3, &extra) -} - -const X5_HEIMDALL: &str = "Libby, post your two lines."; - -/// The recorded model of the X.5 tests: with `failing`, Libby's first Interpreter call that lists Heimdall's line fails, as -/// R17's did ("the provider failed the call: Provider", 4096 out). -struct X5Model { - inner: Scripted, - failing: bool, - failed: std::cell::Cell, -} - -fn x5_model(failing: bool) -> X5Model { - let inner = Scripted::new(|prompt| if is_tobiah(prompt) { "Nothing here for me.".into() } else { "Heimdall has ruled, so I post.\n\nWelcome. Say hello whenever you like.".into() }); - X5Model { inner, failing, failed: std::cell::Cell::new(0) } -} - -fn libby_turns(run: &Value) -> Vec<&Value> { - run["turns"].as_array().unwrap().iter().filter(|turn| turn["persona"] == "Libby").collect() -} - /// A newcomer's untagged hello in a public room, said at `round`, appended to a plan. fn hello(path: &Path, round: usize) { let mut text = std::fs::read_to_string(path).unwrap(); diff --git a/crates/mind-body/src/projection/span.rs b/crates/mind-body/src/projection/span.rs index 0db8513..56d7187 100644 --- a/crates/mind-body/src/projection/span.rs +++ b/crates/mind-body/src/projection/span.rs @@ -37,6 +37,3 @@ pub(crate) fn tokens(text: &str) -> impl Iterator { let folded = fold_text(text).to_lowercase(); folded.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).map(str::to_owned).collect::>().into_iter() } - -#[cfg(test)] -mod tests; diff --git a/crates/mind-body/src/projection/span/tests.rs b/crates/mind-body/src/projection/span/tests.rs deleted file mode 100644 index 7e63b28..0000000 --- a/crates/mind-body/src/projection/span/tests.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Ghostlight's locator tests (`ghostlight-persona-projection` at `c43eb54`), copied for Huginn's locator, and its fold. - -use super::*; - diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 76beadc..c807875 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -8,7 +8,7 @@ use anyhow::Result; use chrono::{DateTime, Utc}; use serde_json::{Value, json}; -use super::narrate::{INSTRUCTIONS, MAX_OUTPUT_TOKENS, PROJECTOR_OPENING}; +use super::narrate::{PROJECTOR_OPENING}; use super::select::{Lens, Overflow, Pool}; use super::tuning::Tuning; use super::*; @@ -282,15 +282,6 @@ fn a_state_with_one_sense_renders_it_and_a_state_with_none_only_the_turn_line() } } -/// A mouth whose read fails. -struct Deaf; - -impl MouthReader for Deaf { - fn pending(&self) -> Result { - anyhow::bail!("the mouth did not answer") - } -} - #[test] fn the_body_is_read_from_state_and_code_never_from_guidance_or_the_voice() { let mut tuning = Tuning::default(); @@ -989,7 +980,7 @@ fn a_given_state_is_projected_without_reading_the_stored_one() { // --------------------------------------------------------------------------------------------- // KitModel against a real kit server (ported with it from the stream organ). -use model_connector::{CallerAdmission, InputItem, ProviderBackend, ProviderCall, ProviderRequest, ReasoningEffort, ServeLimits, StopReason, TransportEvent, TransportEventPayload, TransportOutcome, TransportResult, Usage, serve as serve_kit}; +use model_connector::{CallerAdmission, ProviderBackend, ProviderCall, ProviderRequest, ServeLimits, StopReason, TransportEvent, TransportEventPayload, TransportOutcome, TransportResult, Usage, serve as serve_kit}; const KIT_KEY: &str = "projector-test-key"; const KIT_MODEL: &str = "claude-haiku-5-5"; @@ -1634,16 +1625,6 @@ fn the_projector_frame_is_huginns_lived_frame_and_carries_no_ghostlight_membrane assert!(!prompt.contains("Notes on their present"), "the sections carry their own headings: {prompt}"); } -/// Whether a text calls someone "she" or "her", as a word. -fn says_she(text: &str) -> bool { - text.split(|c: char| !c.is_alphabetic()).any(|word| word.eq_ignore_ascii_case("she") || word.eq_ignore_ascii_case("her") || word.eq_ignore_ascii_case("hers") || word.eq_ignore_ascii_case("herself")) -} - -/// The bonds of `state()`, so a packet shows people here. -fn state_value_affect() -> Value { - json!({ "socialBonds": state()["affect"]["socialBonds"].clone() }) -} - #[test] fn the_narration_checks_flag_an_option_menu_and_a_retelling_and_pass_a_reaction() { // Round 1 of the humans_pace run of 2026-11-20, as the Projector wrote it. @@ -2111,17 +2092,6 @@ fn the_arrival_survives_a_busy_room() { // --------------------------------------------------------------------------------------------- // K23: her domain (map 16.22.2). -fn packet_with_domain(digest: Option<&domain::Digest>, tuning: &Tuning) -> Packet { - let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room()); - let inputs = Inputs { kind: TurnKind::Chat, state: &state(), room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: digest, exchange: None }; - select(&inputs, tuning) -} - -/// The lines of her domain in her view, its heading excluded: the window's headings and the items under them. -fn domain_section(packet: &Packet) -> Vec { - packet.in_view.lines().skip_while(|line| *line != "Her domain, as she looks at it now:").skip(1).map(str::to_owned).collect() -} - /// Nine merged pull requests, one an hour back from an hour ago, in a window that opened two days ago. fn nine() -> domain::Digest { let items = (1..=9) @@ -2210,18 +2180,3 @@ fn r7_no_clock_time_appears_anywhere_in_the_persona_prompt() { // Libby wrote the held welcome into a line "only for Meta", because code's speech form told her a line could go "to one // person". The form now states where whatever goes out goes, as a fact of this turn's room. -const X5_META_R1: &str = "Libby, write out the two-line welcome you'd post for newcomers, but hold it, don't post it in here yet. Heimdall still has to rule on whether we put a welcome mat out at all. Just tell me when it's ready."; - -/// X.5 r1's room as Libby's stimulus shows it: Meta's line to her, then Deru's and Meta's lines to others, in #minds. -fn x5_r1_room() -> Room { - Room { - messages: vec![ - message("#minds:gamecult.org", "@deru:gamecult.org", "Deru", "Nibu, Aqua: found this on physical modelling of plosives and waveguides, thought of you two https://ccrma.stanford.edu/~jos/pasp/", 3, false), - message("#minds:gamecult.org", OPERATOR, "Meta", "Eureka, can you look at GameCult/gamecult-ops#125 and tell me whether the relay revert in it looks safe? no rush", 2, false), - message("#minds:gamecult.org", OPERATOR, "Meta", X5_META_R1, 1, true), - ], - here: Some("#minds:gamecult.org".into()), - ..Room::default() - } -} -