From b2fccb33a126a3023ccf6cb152eb203527f2c5dd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 21 Nov 2026 00:05:59 +0100 Subject: [PATCH] K24: her next outcome tells her of reads a cap or a rule refused, in code's words; what it was only when a cap refused a resolved read Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection.rs | 7 +++- .../mind-body/src/projection/harness/tests.rs | 22 ++++++++++ crates/mind-body/src/projection/outcome.rs | 16 +++++++- crates/mind-body/src/projection/read.rs | 40 +++++++++++++++++++ 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/crates/mind-body/src/projection.rs b/crates/mind-body/src/projection.rs index 427fcee..3627af8 100644 --- a/crates/mind-body/src/projection.rs +++ b/crates/mind-body/src/projection.rs @@ -434,7 +434,12 @@ fn narrate_one(model: &dyn Model, instance: &str, packet: &Packet, tuning: &tuni let words_left = (tuning.persona.words * 2).saturating_sub(words(&prose)); let bytes_left = tuning.interpreter.wake_read_bytes.saturating_sub(read_bytes); if reads.len() >= tuning.interpreter.reads_per_wake || bytes_left == 0 || words_left < tuning.persona.words { - ended = Some(if reads.len() >= tuning.interpreter.reads_per_wake { "reads_per_wake" } else if bytes_left == 0 { "wake_read_bytes" } else { "prose_words" }); + let cap = if reads.len() >= tuning.interpreter.reads_per_wake { "reads_per_wake" } else if bytes_left == 0 { "wake_read_bytes" } else { "prose_words" }; + ended = Some(cap); + // A read a cap refuses is recorded with what it was, and told to her next wake (`outcome`). + let mut refused = decision["read_refused"].as_array().cloned().unwrap_or_default(); + refused.push(json!({ "read": read, "why": cap, "what": read["what"] })); + decision["read_refused"] = json!(refused); break; } let Ok(request) = serde_json::from_value::(read["request"].clone()) else { break }; diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index 03baa50..475d2c1 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -521,3 +521,25 @@ fn k24_every_call_of_a_reading_wake_is_counted() { let counted: u64 = usage_total(std::slice::from_ref(&report)).values().map(|row| row["calls"]).sum(); assert_eq!((counted, model.calls.borrow().len()), (5, 5), "projector, persona, interpreter, continuation, interpreter"); } + +/// Soul at 7d43695: a read a cap or a rule refused is told to her next wake too, in code's words; what it was only when a +/// cap refused a read already resolved. +#[test] +fn k24_her_next_outcome_tells_her_of_reads_refused_by_a_cap_or_a_rule() { + let fixture = reading_room("quiet-beat.toml"); + let model = Scripted::new(|prompt| if prompt.contains("LOOP-READ") { "So the knee goes first. I want to see what changed in GameCult/Lodur#12 again.".into() } else { "I want to see what changed in GameCult/Lodur#12.".into() }).interpreting(|_| { + json!({ "say": [], "gaps": [], "read": { "kind": "repo", "target": "GameCult/Lodur#12", "quote": "I want to see what changed" } }).to_string() + }); + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("persona-tuning.toml"), "[interpreter] +reads_per_wake = 1 +").unwrap(); + let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: Some(&model), domain: None, reads: fixture.reads() }; + let report = project(&organs, &fixture_request(&harness(dir.path(), None, Some(&model)), &fixture, Some(control()), 1, Some(1), Through::Interpreter), fixture.now).unwrap(); + let mut decision = report["renders"][0]["interpreter"].clone(); + assert_eq!(decision["read_refused"][0]["why"], "reads_per_wake", "{decision}"); + decision["read_refused"].as_array_mut().unwrap().push(json!({ "read": { "kind": "web", "target": "http://made.up/x", "quote": "x" }, "why": "web_address_not_in_front_of_her" })); + let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] })).unwrap().lines(crate::projection::select::forms(&control())); + assert!(told.contains(&"- He reached for GameCult/Lodur#12 on the forge and it was not read: he has read as much as one turn reads.".to_owned()), "{told:?}"); + assert!(told.contains(&"- He reached for something to read and it was not read: the address was not in front of him.".to_owned()) && !told.join("\n").contains("made.up"), "a model's target is never told: {told:?}"); +} diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs index 5d7ccef..fc18fe1 100644 --- a/crates/mind-body/src/projection/outcome.rs +++ b/crates/mind-body/src/projection/outcome.rs @@ -21,7 +21,7 @@ use serde_json::Value; use super::commit::{How, Refusal as StateRefusal}; use super::interpret::{GapKind, MAX_LINES, Refusal}; -use super::read::ReadFailure; +use super::read::{ReadFailure, ReadRefusal}; use super::select::{Forms, capitalized, clip, spoken}; /// A line of hers that went out, as the actuator's receipt names it. @@ -85,6 +85,9 @@ enum Part { Read { what: String, quote: String }, /// A read that returned nothing, and why, from code's table. ReadFailed { what: String, failure: ReadFailure }, + /// A read she reached for that a rule or a cap refused, and why; what it was only when a cap refused it, since a + /// read a rule refused was never resolved. + ReadRefused { what: Option, why: ReadRefusal }, } /// What came of her last turn: what she is told, what she is not and why, and the lines that went out. @@ -233,6 +236,12 @@ pub(crate) fn outcome_of(record: &Value) -> Option { _ => outcome.omitted.push(format!("a read she cannot be told truly: {read}")), } } + for refused in decision["read_refused"].as_array().into_iter().flatten() { + match serde_json::from_value::(refused["why"].clone()) { + Ok(why) => outcome.parts.push(Part::ReadRefused { what: words(&refused["what"]).filter(|_| why.cap()), why }), + Err(_) => outcome.omitted.push(format!("a refused read she cannot be told truly: {refused}")), + } + } if let Some(text) = words(&decision["unfinished"]) { outcome.parts.push(Part::Unfinished { room: room.clone(), text }); } @@ -279,7 +288,7 @@ impl Part { fn rank(&self) -> u8 { match self { Self::Failed => 0, - Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } | Self::ReadFailed { .. } => 1, + Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1, Self::Promise { .. } | Self::Amended { promise: true, .. } => 2, Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Closed { .. } | Self::Read { .. } => 3, Self::BrokeAfter { .. } => 4, @@ -312,6 +321,8 @@ impl Part { Self::StillOpen { to, words, .. } => format!("{} promise to {to}, {}, is still open:", capitalized(poss), quoted(words)), Self::Read { what, quote } => format!("{cap_subj} read {what}, because of {poss} thought: {}.", quoted(quote)), Self::ReadFailed { what, .. } => format!("{cap_subj} reached for {what} and could not read it:"), + 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:"), } } @@ -369,6 +380,7 @@ impl Part { Self::BrokeAfter { .. } => format!(" the rest of that turn broke off, not by {poss} choice."), Self::Read { .. } => format!(" It is not in front of {obj} now."), Self::ReadFailed { failure, .. } => format!(" {}.", failure.words()), + 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 97449df..f533a6d 100644 --- a/crates/mind-body/src/projection/read.rs +++ b/crates/mind-body/src/projection/read.rs @@ -114,6 +114,46 @@ impl ReadFailure { } } +/// Why a read she reached for was not performed: a rule `interpret::reading` holds, or a cap of her wake (map 16.22.3). +/// Her next outcome tells her, in these words and no model's. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ReadRefusal { + NoReadHere, + NotTheContract, + QuoteNotInHerThought, + NoSuchDomainLine, + NoRecallWords, + NotAGamecultRepo, + WebAddressNotInFrontOfHer, + ReadsPerWake, + WakeReadBytes, + ProseWords, +} + +impl ReadRefusal { + /// Whether a cap refused it: then the read was resolved, and what it was can be told. + pub(crate) fn cap(self) -> bool { + matches!(self, Self::ReadsPerWake | Self::WakeReadBytes | Self::ProseWords) + } + + pub(crate) fn words(self, her: Forms) -> String { + let Forms { subj, obj, poss, has, .. } = her; + match self { + Self::NoReadHere => "that turn could not read".to_owned(), + Self::NotTheContract => "the read could not be named".to_owned(), + Self::QuoteNotInHerThought => format!("nothing in {poss} thought reached for it"), + 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(), + Self::WebAddressNotInFrontOfHer => format!("the address was not in front of {obj}"), + Self::ReadsPerWake => format!("{subj} {has} read as much as one turn reads"), + Self::WakeReadBytes => format!("{subj} {has} read as much as one turn holds"), + Self::ProseWords => format!("{poss} thought {has} run as long as one turn runs"), + } + } +} + /// What performs her reads. Read-only by type: nothing here writes, sends or admits. pub trait ReadSource { /// The text of `request`, verbatim; `since` is when her domain's window opened, for a campaign read.