From 51ab9a864e46dba1f470b3426d44488ea5f92085 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 21 Nov 2026 02:19:31 +0100 Subject: [PATCH] Persona reads: one normal form per target; a read already made in this conversation, found or not, is refused and told Soul's R7 item 2. ReadRequest::normal makes the org and repo case-blind and a search's words lowercase with collapsed spaces, order kept. The exchange records every read she made in the conversation (found or not-found) as Tried, and the packet carries that list in place of the reads whose results happen to be shown. A read matching one, or one made earlier this wake, is refused as in_view or in_view_not_found, and since the refusal is her own act she is told: "She already read X earlier in this conversation" / "already looked for X ... and it was not there". Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/exchange.rs | 53 +++++++++++++------ .../src/projection/exchange/tests.rs | 19 +++++-- crates/mind-body/src/projection/interpret.rs | 28 +++++----- .../src/projection/interpret/tests.rs | 34 ++++++++---- crates/mind-body/src/projection/outcome.rs | 5 +- crates/mind-body/src/projection/read.rs | 33 ++++++++++-- crates/mind-body/src/projection/select.rs | 11 ++-- 7 files changed, 134 insertions(+), 49 deletions(-) diff --git a/crates/mind-body/src/projection/exchange.rs b/crates/mind-body/src/projection/exchange.rs index e62d953..07a22fa 100644 --- a/crates/mind-body/src/projection/exchange.rs +++ b/crates/mind-body/src/projection/exchange.rs @@ -28,15 +28,31 @@ pub(crate) const EXCHANGE_MINUTES: i64 = 30; pub(crate) struct Did { pub(crate) at: DateTime, pub(crate) text: String, - /// The read this is, when it is one: a read whose result is shown is in her view. - pub(crate) read: Option, } -/// Her side of the conversation, oldest first: her lines, then each distinct read once with its latest result. +/// Her side of the conversation, oldest first: her lines, then each distinct read once with its latest result; and +/// every read she made in it, shown or not, found or not, by its normal form (Soul's R7). #[derive(Clone, Debug, Default, PartialEq, Eq)] pub(crate) struct Exchange { pub(crate) lines: Vec, - pub(crate) reads: Vec, + pub(crate) reads: Vec, + pub(crate) tried: Vec, +} + +/// A read's latest result as her view shows it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct Shown { + pub(crate) at: DateTime, + pub(crate) key: String, + pub(crate) text: String, +} + +/// A read she made in this conversation: its normal form, whether it found anything, and what it was in code's words. +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] +pub(crate) struct Tried { + pub(crate) key: String, + pub(crate) found: bool, + pub(crate) what: String, } fn at_of(record: &Value) -> Option> { @@ -80,15 +96,23 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime, her .filter(|amended| amended["event"].as_str() == Some(event)) .filter_map(|amended| amended["added"].as_str().map(|added| format!(" ({} added: {})", her.subj, spoken(added)))) .collect(); - exchange.lines.push(Did { at: *at, text: format!("- {}{reply}: {}{}", time_of(*at, now), spoken(text), added.join("")), read: None }); + exchange.lines.push(Did { at: *at, text: format!("- {}{reply}: {}{}", time_of(*at, now), spoken(text), added.join("")) }); + } + for read in decision["reads"].as_array().into_iter().flatten() { + let Ok(request) = serde_json::from_value::(read["request"].clone()) else { continue }; + let found = read["ok"] == true; + if found || read["failure"] == "not_found" { + exchange.tried.retain(|tried| tried.key != request.normal()); + exchange.tried.push(Tried { key: request.normal(), found, what: read["what"].as_str().unwrap_or_default().to_owned() }); + } } for read in decision["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == true) { let (Ok(request), Some(what), Some(text)) = (serde_json::from_value::(read["request"].clone()), read["what"].as_str(), read["text"].as_str()) else { continue }; // Each distinct thing once, its latest result. - exchange.reads.retain(|done| done.read.as_ref() != Some(&request)); + exchange.reads.retain(|done| done.key != request.normal()); let longest = text.split(|c| c != '`').map(str::len).max().unwrap_or(0); let fence = "`".repeat(longest.max(3) + 1); - exchange.reads.push(Did { at: *at, text: format!("{} read {what} ({}):\n{fence}\n{text}\n{fence}", capitalized(her.subj), time_of(*at, now)), read: Some(request) }); + exchange.reads.push(Shown { at: *at, key: request.normal(), text: format!("{} read {what} ({}):\n{fence}\n{text}\n{fence}", capitalized(her.subj), time_of(*at, now)) }); } } exchange @@ -97,23 +121,22 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime, her /// Her side of the conversation as her view shows it, under `budget` bytes, heading included, and the reads it shows: /// everything, or, when it does not fit, the window shrunk from its old end a whole minute at a time, whole lines and /// whole results only, the heading saying since when. Empty when she has done nothing here, or not even the newest fits. -pub(crate) fn render(exchange: &Exchange, her: Forms, budget: usize, now: DateTime) -> (String, Vec) { - let all: Vec<&Did> = exchange.lines.iter().chain(&exchange.reads).collect(); - let Some(mut start) = all.iter().map(|did| did.at).min() else { return (String::new(), Vec::new()) }; +pub(crate) fn render(exchange: &Exchange, her: Forms, budget: usize, now: DateTime) -> String { + let Some(mut start) = exchange.lines.iter().map(|did| did.at).chain(exchange.reads.iter().map(|shown| shown.at)).min() else { return String::new() }; let mut shrunk = false; loop { let lines: Vec<&Did> = exchange.lines.iter().filter(|did| did.at >= start).collect(); - let reads: Vec<&Did> = exchange.reads.iter().filter(|did| did.at >= start).collect(); + let reads: Vec<&Shown> = exchange.reads.iter().filter(|shown| shown.at >= start).collect(); if lines.is_empty() && reads.is_empty() { - return (String::new(), Vec::new()); + return String::new(); } let since = if shrunk { format!(" since {}", time_of(start, now)) } else { String::new() }; let heading = format!("What {} {} said and read in this conversation{since}:", her.subj, her.has); - let block = std::iter::once(heading).chain(lines.iter().chain(&reads).map(|did| did.text.clone())).collect::>().join("\n"); + let block = std::iter::once(heading).chain(lines.iter().map(|did| did.text.clone())).chain(reads.iter().map(|shown| shown.text.clone())).collect::>().join("\n"); if block.len() <= budget { - return (block, reads.iter().filter_map(|did| did.read.clone()).collect()); + return block; } - let oldest = lines.iter().chain(&reads).map(|did| did.at).min().unwrap_or(now); + let oldest = lines.iter().map(|did| did.at).chain(reads.iter().map(|shown| shown.at)).min().unwrap_or(now); start = floor_minute(oldest) + chrono::Duration::minutes(1); shrunk = true; } diff --git a/crates/mind-body/src/projection/exchange/tests.rs b/crates/mind-body/src/projection/exchange/tests.rs index b57d798..e086f42 100644 --- a/crates/mind-body/src/projection/exchange/tests.rs +++ b/crates/mind-body/src/projection/exchange/tests.rs @@ -36,10 +36,11 @@ fn k26_her_side_of_the_conversation_is_her_lines_and_her_reads_while_it_lasts() turn(25, MINDS, &[], json!([read("GameCult/Bifrost", "NEW Bifrost list"), read("GameCult/Lodur#12", "Reflex: the knee bends first.")]), json!([{ "event": "e1", "added": "Checked: it does." }]), json!([{ "event": "e1", "refusal": null }])), ]; let exchange = exchange_of(&records, MINDS, now(), her()); - let (view, reads) = render(&exchange, her(), 3000, now()); + let view = render(&exchange, her(), 3000, now()); assert_eq!(view, "What he has said and read in this conversation:\n- 14:10 UTC, replying to Meta: \"The knee bends first, I think.\" (he added: \"Checked: it does.\")\nHe read GameCult/Bifrost on the forge (14:35 UTC):\n````\nNEW Bifrost list\n````\nHe read GameCult/Lodur#12 on the forge (14:35 UTC):\n````\nReflex: the knee bends first.\n````"); assert!(!view.contains("LONG-AGO") && !view.contains("OTHER-ROOM") && !view.contains("OLD Bifrost"), "past the pause, another room, and an older result of the same read are not shown"); - assert_eq!(reads, [ReadRequest::Repo("GameCult/Bifrost".into()), ReadRequest::Repo("GameCult/Lodur#12".into())]); + let keys: Vec<&str> = exchange.tried.iter().map(|tried| tried.key.as_str()).collect(); + assert_eq!(keys, ["repo:gamecult/bifrost", "repo:gamecult/lodur#12"], "every read made, once, by its normal form"); // A pause of more than the window since her last turn: a fresh conversation. assert!(exchange_of(&records, MINDS, now() + Duration::minutes(EXCHANGE_MINUTES), her()).lines.is_empty()); } @@ -51,7 +52,17 @@ fn k26_past_its_budget_the_window_shrinks_and_nothing_is_counted() { turn(20, MINDS, &[("e2", "SECOND line of mine.", None)], json!([]), json!([]), json!([])), ]; let exchange = exchange_of(&records, MINDS, now(), her()); - let (view, _) = render(&exchange, her(), 110, now()); + let view = render(&exchange, her(), 110, now()); assert_eq!(view, "What he has said and read in this conversation since 14:21 UTC:\n- 14:40 UTC: \"SECOND line of mine.\""); - assert!(render(&exchange, her(), 20, now()).0.is_empty(), "not even the newest fits: none"); + assert!(render(&exchange, her(), 20, now()).is_empty(), "not even the newest fits: none"); +} + +/// Soul's R7: a read that came back not-found is in the conversation's record too, so it is never made again; one that +/// failed otherwise (private, too large, broken) is not. +#[test] +fn r7_a_not_found_read_is_remembered_and_a_broken_one_is_not() { + let missing = json!({ "ok": false, "failure": "not_found", "request": { "kind": "repo", "target": "GameCult/Bifrost?q=Consent Receipt" }, "what": "a search" }); + let broken = json!({ "ok": false, "failure": "failed", "request": { "kind": "repo", "target": "GameCult/Lodur" }, "what": "GameCult/Lodur on the forge" }); + let exchange = exchange_of(&[turn(10, MINDS, &[], json!([missing, broken]), json!([]), json!([]))], MINDS, now(), her()); + assert_eq!(exchange.tried, [Tried { key: "repo:gamecult/bifrost?q=consent receipt".into(), found: false, what: "a search".into() }]); } diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index e8184a0..724cec2 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -468,7 +468,7 @@ pub(crate) fn speech_prompt_in(packet: &Packet, narration: &str, prose: &str, tu let guidance = if guidance.is_empty() { String::new() } else { format!("{guidance}\n\n") }; // What she can read, and how to name it, only when this turn can read (map 16.22.3); and what is already in her view, // not to be read again (K26). - let in_view = if packet.in_view_reads.is_empty() { String::new() } else { format!(" Already in {} view, so never named as a read: {}.", her.poss, packet.in_view_reads.iter().map(|read| read.what(her)).collect::>().join("; ")) }; + let in_view = if packet.already_read.is_empty() { String::new() } else { format!(" Already read in this conversation, so never named as a read: {}.", packet.already_read.iter().map(|tried| if tried.found { tried.what.clone() } else { format!("{} (nothing was there)", tried.what) }).collect::>().join("; ")) }; let reading = if packet.affordances.contains(&Affordance::Read) { format!("{}{in_view}\n\n", read_frame(her)) } else { String::new() }; // Her earlier segments this wake, already decided on: context, never hers to send again. // Her earlier segments this wake and what she read between them. Her drafts are numbered across the whole moment, and @@ -713,7 +713,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na if let Some(raw) = parsed.read.filter(|raw| !raw.is_null()) { match reading(&raw, packet, prose, &found, wake) { Ok(read) => decision["read"] = read, - Err(why) => read_refused.push(json!({ "read": raw, "why": why })), + Err((why, what)) => read_refused.push(json!({ "read": raw, "why": why, "what": what })), } } if !read_refused.is_empty() { @@ -723,20 +723,24 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na } /// A read the answer names, resolved: its request, what it is in code's words, and the passage of her thought in this -/// segment that reaches for it. Why not, when not. -fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake) -> Result { +/// segment that reaches for it. Why not, when not, with what it was in code's words when it resolved (Soul's R7: a read +/// she already made is told by name). +fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake) -> Result)> { if !packet.affordances.contains(&Affordance::Read) { - return Err("no_read_here"); + return Err(("no_read_here", None)); } - let asked: Asked = serde_json::from_value(raw.clone()).map_err(|_| "not_the_contract")?; + let asked: Asked = serde_json::from_value(raw.clone()).map_err(|_| ("not_the_contract", None))?; // In front of her is her prose and what she was sent, never what she read: a read cannot chain from a fetched page // (Soul's p1b), so no page can steer her to the next. let reached: Vec = packet.bodies.iter().cloned().chain(std::iter::once(packet.heard.clone())).collect(); - let request = resolve(&asked, packet, prose, &reached)?; - // What is in her view is not read again (K26): its latest result is there, from this conversation or this wake. - let read_this_wake = wake.earlier.into_iter().flat_map(|earlier| earlier["reads"].as_array().cloned().unwrap_or_default()).any(|done| done["ok"] == true && serde_json::from_value::(done["request"].clone()).is_ok_and(|done| done == request)); - if packet.in_view_reads.contains(&request) || read_this_wake { - return Err("in_view"); + let request = resolve(&asked, packet, prose, &reached).map_err(|why| (why, None))?; + // Nothing she read in this conversation, or this wake, is read again (K26, Soul's R7), found or not, shown or not. + let key = request.normal(); + let this_wake = wake.earlier.into_iter().flat_map(|earlier| earlier["reads"].as_array().cloned().unwrap_or_default()).find(|done| (done["ok"] == true || done["failure"] == "not_found") && serde_json::from_value::(done["request"].clone()).is_ok_and(|done| done.normal() == key)).map(|done| done["ok"] == true); + match packet.already_read.iter().find(|tried| tried.key == key).map(|tried| tried.found).or(this_wake) { + Some(true) => return Err(("in_view", Some(request.what(packet.forms)))), + Some(false) => return Err(("in_view_not_found", Some(request.what(packet.forms)))), + None => {} } // The reach is located in her thought in this segment: the Interpreter's quote, or failing that the longest run of at // least `SPAN_MIN_WORDS` of its words found there (Soul's R5), and only where the sentence it stands in names what is @@ -756,7 +760,7 @@ fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake let whole = (quote.len() >= QUOTE_MIN_WORDS).then(|| locate("e.join(" "))).flatten(); let located = whole .or_else(|| (SPAN_MIN_WORDS..=quote.len()).rev().find_map(|size| quote.windows(size).find_map(|span| locate(&span.join(" "))))) - .ok_or("quote_not_located")?; + .ok_or(("quote_not_located", None))?; Ok(json!({ "kind": asked.kind, "target": asked.target.trim(), "request": request, "what": request.what(packet.forms), "quote": located })) } diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index c49def6..709d568 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -903,18 +903,34 @@ fn r6_anyone_named_gets_their_pronouns_in_view_or_not() { assert!(persona.contains("Pronouns of the people named here:") && persona.contains("Kiko \u{2014} she/her"), "{persona}"); } -/// K26: what is in her view is never read again. A read whose latest result her view shows is refused as `in_view`, -/// reported and not told; the Interpreter is shown which targets those are. +/// K26, Soul's R7: nothing she read in this conversation is read again, shown or not, found or not, by its normal form +/// (the repo case-blind, a search's words lowercased and collapsed). The refusal is her own act, so she is told it. #[test] -fn k26_a_read_already_in_her_view_is_not_read_again() { +fn r7_a_read_already_made_in_this_conversation_is_refused_and_told() { + use crate::projection::exchange::Tried; + use crate::projection::read::ReadRequest; let mut reading = reading_packet(); - reading.in_view_reads = vec![crate::projection::read::ReadRequest::Repo("GameCult/Lodur".into())]; - let prose = "I want to see what Nibu changed in Lodur."; - let again = asked(&reading, prose, json!({ "kind": "domain", "target": "d1", "quote": "I want to see what Nibu changed in Lodur" })); + let tried = |target: &str, found| Tried { key: ReadRequest::Repo(target.into()).normal(), found, what: format!("{target} on the forge") }; + reading.already_read = vec![tried("GameCult/Lodur", true), tried("GameCult/Bifrost?q=consent receipt", false)]; + let prose = "I want to see what Nibu changed in Lodur. And the Bifrost change about the Consent Receipt."; + let again = asked(&reading, prose, json!({ "kind": "repo", "target": "gamecult/LODUR", "quote": "I want to see what Nibu changed in Lodur" })); assert_eq!((again["read"].clone(), again["read_refused"][0]["why"].as_str()), (Value::Null, Some("in_view")), "{again}"); - let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": again, "posted": [] })).unwrap(); - assert!(outcome.lines(packet().forms).is_empty(), "reported, never told"); - assert!(speech_prompt(&reading, "x", prose, &Tuning::default()).contains("Already in his view, so never named as a read: GameCult/Lodur on the forge.")); + let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": again, "posted": [] })).unwrap().lines(packet().forms); + assert!(told.iter().any(|line| line.contains("He already read GameCult/LODUR on the forge earlier in this conversation.")), "{told:?}"); + let missing = asked(&reading, prose, json!({ "kind": "repo", "target": "GameCult/bifrost?q=Consent Receipt", "quote": "And the Bifrost change about the Consent" })); + assert_eq!(missing["read_refused"][0]["why"], "in_view_not_found", "{missing}"); + let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": missing, "posted": [] })).unwrap().lines(packet().forms); + assert!(told.iter().any(|line| line.contains("already looked for") && line.contains("and it was not there.")), "{told:?}"); + let prompt = speech_prompt(&reading, "x", prose, &Tuning::default()); + assert!(prompt.contains("Already read in this conversation, so never named as a read: GameCult/Lodur on the forge; GameCult/Bifrost?q=consent receipt on the forge (nothing was there)."), "{prompt}"); + // This wake's own earlier read, by the same normal form. + let wake_read = json!({ "reads": [{ "ok": true, "request": { "kind": "repo", "target": "GameCult/Lodur" } }] }); + let fresh = reading_packet(); + let wake = Wake { earlier: Some(&wake_read), ..Wake::default() }; + let reply = json!({ "say": [], "gaps": [], "read": { "kind": "repo", "target": "GameCult/lodur", "quote": "I want to see what Nibu changed in Lodur" } }).to_string(); + let model = Scripted::new(|_| String::new()).interpreting(move |_| reply.clone()); + let twice = decide_in(&model, "test", &fresh, "The room is warm.", prose, &Tuning::default(), wake); + assert_eq!(twice["read_refused"][0]["why"], "in_view", "{twice}"); } /// K28 (map 16.24.3): a search's words must stand in her prose; a search the Interpreter made up is refused and not told. diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs index b7e69e2..7e189ba 100644 --- a/crates/mind-body/src/projection/outcome.rs +++ b/crates/mind-body/src/projection/outcome.rs @@ -247,7 +247,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option { } for refused in decision["read_refused"].as_array().into_iter().flatten() { match serde_json::from_value::(refused["why"].clone()) { - Ok(why) if why.told() => outcome.parts.push(Part::ReadRefused { what: words(&refused["what"]).filter(|_| why.cap()), why }), + Ok(why) if why.told() => outcome.parts.push(Part::ReadRefused { what: words(&refused["what"]).filter(|_| why.names_what()), why }), Ok(_) => outcome.omitted.push(format!("a read refused for the Interpreter's fault, not hers: {refused}")), Err(_) => outcome.omitted.push(format!("a refused read she cannot be told truly: {refused}")), } @@ -335,6 +335,8 @@ impl Part { Self::StillOpen { to, words, .. } => format!("{} promise to {to}, {}, is still open:", capitalized(poss), quoted(words)), Self::Read { what } => format!("{cap_subj} read {what}."), Self::ReadFailed { what, .. } => format!("{cap_subj} reached for {what} and could not read it:"), + Self::ReadRefused { what: Some(what), why: ReadRefusal::InView } => format!("{cap_subj} already read {what} earlier in this conversation."), + Self::ReadRefused { what: Some(what), why: ReadRefusal::InViewNotFound } => format!("{cap_subj} already looked for {what} earlier in this conversation, and it was not there."), Self::ReadRefused { what: Some(what), .. } => format!("{cap_subj} reached for {what} and it was not read:"), Self::ReadRefused { what: None, .. } => format!("{cap_subj} reached for something to read and it was not read:"), } @@ -395,6 +397,7 @@ impl Part { Self::BrokeAfter { .. } => format!(" the rest of that turn broke off, not by {poss} choice."), Self::Read { .. } => String::new(), Self::ReadFailed { failure, .. } => format!(" {}.", failure.words()), + Self::ReadRefused { what: Some(_), why: ReadRefusal::InView | ReadRefusal::InViewNotFound } => String::new(), Self::ReadRefused { why, .. } => format!(" {}.", why.words(her)), } } diff --git a/crates/mind-body/src/projection/read.rs b/crates/mind-body/src/projection/read.rs index 17a7311..1811a96 100644 --- a/crates/mind-body/src/projection/read.rs +++ b/crates/mind-body/src/projection/read.rs @@ -74,6 +74,25 @@ pub enum ReadRequest { } impl ReadRequest { + /// One normal form per thing read (Soul's R7): the org and repo case-blind, a search's words lowercased with their + /// spaces collapsed and their order kept, a recall's and a campaign's lowercased. Two requests with the same form are + /// the same read. + pub(crate) fn normal(&self) -> String { + let collapse = |text: &str| text.split_whitespace().collect::>().join(" ").to_lowercase(); + match self { + Self::Repo(target) => { + let rest = target.get("GameCult/".len()..).unwrap_or(target); + let end = rest.find(['/', '#', '@', '?']).unwrap_or(rest.len()); + let (name, suffix) = rest.split_at(end); + let suffix = suffix.strip_prefix("?q=").map_or_else(|| suffix.to_owned(), |words| format!("?q={}", collapse(words))); + format!("repo:gamecult/{}{suffix}", name.to_lowercase()) + } + Self::Campaign(slug) => format!("campaign:{}", slug.to_lowercase()), + Self::Mind(words) => format!("mind:{}", collapse(words)), + Self::Web(url) => format!("web:{url}"), + } + } + /// What she read, in code's words for her outcome and her bridge: never a model's words (a recall's query is the /// Interpreter's, so it is not repeated). pub(crate) fn what(&self, her: Forms) -> String { @@ -131,8 +150,10 @@ pub(crate) enum ReadRefusal { MalformedTarget, /// A search whose words are not in her prose (map 16.24.3). SearchWordsNotInHerThought, - /// Its latest result is in her view already (K26). + /// She read it already in this conversation (K26, Soul's R7): her own act, told to her. InView, + /// She looked for it already in this conversation, and it was not there. + InViewNotFound, NoSuchDomainLine, NoRecallWords, NotAGamecultRepo, @@ -147,7 +168,7 @@ impl ReadRefusal { /// GameCult. A refusal that is the Interpreter's fault (a quote it could not locate, a malformed or unknown target, an /// answer off the contract) is reported and never told to her as hers (Soul's R5). pub(crate) fn told(self) -> bool { - matches!(self, Self::ReadsPerWake | Self::WakeReadBytes | Self::ProseWords | Self::NoReadHere | Self::WebAddressNotInFrontOfHer | Self::NotAGamecultRepo) + matches!(self, Self::ReadsPerWake | Self::WakeReadBytes | Self::ProseWords | Self::NoReadHere | Self::WebAddressNotInFrontOfHer | Self::NotAGamecultRepo | Self::InView | Self::InViewNotFound) } /// Whether a cap refused it: then the read was resolved, and what it was can be told. @@ -155,6 +176,11 @@ impl ReadRefusal { matches!(self, Self::ReadsPerWake | Self::WakeReadBytes | Self::ProseWords) } + /// Whether what the read was is told with it: a cap refused a resolved read, or she read it already. + pub(crate) fn names_what(self) -> bool { + self.cap() || matches!(self, Self::InView | Self::InViewNotFound) + } + pub(crate) fn words(self, her: Forms) -> String { let Forms { subj, obj, poss, has, .. } = her; match self { @@ -163,7 +189,8 @@ impl ReadRefusal { Self::QuoteNotInHerThought | Self::QuoteNotLocated => format!("nothing in {poss} thought reached for it"), Self::MalformedTarget => "the read could not be named".to_owned(), Self::SearchWordsNotInHerThought => format!("{poss} thought did not name what to search for"), - Self::InView => format!("it is in front of {obj} already"), + Self::InView => format!("{subj} already read it earlier in this conversation"), + Self::InViewNotFound => format!("{subj} already looked for it earlier in this conversation, and it was not there"), Self::NoSuchDomainLine => format!("it is no line of what moved in {poss} domain"), Self::NoRecallWords => "there was nothing to recall by".to_owned(), Self::NotAGamecultRepo => "it is not a public GameCult repo".to_owned(), diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index c1535b9..005ee6e 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -37,7 +37,6 @@ use unicode_segmentation::UnicodeSegmentation; use super::Affordance; use super::domain::{About, Digest, Item, floor_minute}; use super::exchange::{self, Exchange}; -use super::read::ReadRequest; use super::outcome::Outcome; use super::tuning::{LensWeights, Tuning}; use crate::address::localpart; @@ -356,8 +355,9 @@ pub(crate) struct Packet { pub now_ms: u64, /// Her own Matrix id: her pronouns are not listed among the people named (`named_pronouns`). pub own_sender: String, - /// The reads whose latest result is in her view this turn: not read again (K26), and marked for the Interpreter. - pub in_view_reads: Vec, + /// Every read she made in this conversation, shown or not, found or not (K26, Soul's R7): never made again, and + /// marked for the Interpreter. + pub already_read: Vec, /// What came of her last turn that the outcome's guard left out, whole: counted in the packet's last outcome line and /// reported here (map 16.20.5, I16.11), never shown to a model. pub unshown: Vec, @@ -2212,10 +2212,11 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { // Her view (map 16.23.1): promises, then her domain; the room follows them in what she reads (`narrate::read_after`). let promises_over = promises_view.len() > tuning.select.promises_bytes; // Her side of the conversation, between her promises and her domain (map 16.24.1). - let (exchange_view, in_view_reads) = inputs.exchange.map(|exchange| exchange::render(exchange, her, tuning.select.exchange_bytes, inputs.now)).unwrap_or_default(); + let exchange_view = inputs.exchange.map(|exchange| exchange::render(exchange, her, tuning.select.exchange_bytes, inputs.now)).unwrap_or_default(); + let already_read = inputs.exchange.map(|exchange| exchange.tried.clone()).unwrap_or_default(); let in_view = [promises_view.as_str(), exchange_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::>().join("\n\n"); let mut sections = context.sizes(); (sections.promises, sections.domain) = (promises_view.len(), domain_view.len()); let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default(); - Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, quotable, promises, domain, domain_shown, in_view, promises_over, now_ms, own_sender: inputs.people.own_sender.to_owned(), in_view_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown } + Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, quotable, promises, domain, domain_shown, in_view, promises_over, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown } }