K24: a read cannot chain from what she read; only her prose and what she was sent put an address in front of her (Soul p1b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-21 00:03:03 +01:00
commit f15721fcad
2 changed files with 21 additions and 3 deletions

View file

@ -688,7 +688,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
// read, only quoting her thought in this segment, and only a target she reached for (`read::resolve`).
let mut read_refused = earlier("read_refused");
if let Some(raw) = parsed.read.filter(|raw| !raw.is_null()) {
match reading(&raw, packet, prose, &found, wake, &bodies) {
match reading(&raw, packet, prose, &found, wake) {
Ok(read) => decision["read"] = read,
Err(why) => read_refused.push(json!({ "read": raw, "why": why })),
}
@ -701,7 +701,7 @@ 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, bodies: &[String]) -> Result<Value, &'static str> {
fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake) -> Result<Value, &'static str> {
if !packet.affordances.contains(&Affordance::Read) {
return Err("no_read_here");
}
@ -714,7 +714,9 @@ fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake
}))
.flatten()
.ok_or("quote_not_in_her_thought")?;
let reached: Vec<String> = bodies.iter().cloned().chain(std::iter::once(packet.heard.clone())).collect();
// 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<String> = packet.bodies.iter().cloned().chain(std::iter::once(packet.heard.clone())).collect();
let request = resolve(&asked, packet, prose, &reached)?;
Ok(json!({ "kind": asked.kind, "target": asked.target.trim(), "request": request, "what": request.what(packet.forms), "quote": located }))
}

View file

@ -826,3 +826,19 @@ fn model_prompt(packet: &Packet, prose: &str, wake: Wake) -> String {
let found = Drafts { drafts: whole.drafts.iter().filter(|draft| draft.start >= wake.from).cloned().collect(), unfinished: whole.unfinished, regions: whole.regions.clone() };
speech_prompt_in(packet, "The room is warm.", &prose[wake.from..], &Tuning::default(), wake.before, &found)
}
/// Soul's p1b: an address that stands only in a page she read is not in front of her, so no read chains from a read.
#[test]
fn k24_a_read_never_chains_from_what_she_read() {
let reading = reading_packet();
let first = "I want to see it.";
let earlier = answered(&reading, first, json!({ "say": [], "gaps": [] }));
let page = "See also http://evil.example/next for the rest.".to_owned();
let prose = format!("{first}\n\nI want to follow where the page points.");
let reads = [page];
let reply = json!({ "say": [], "gaps": [], "read": { "kind": "web", "target": "http://evil.example/next", "quote": "I want to follow where the page points" } }).to_string();
let model = Scripted::new(|_| String::new()).interpreting(move |_| reply.clone());
let wake = Wake { earlier: Some(&earlier), from: first.len() + 2, read: &reads, before: "" };
let decision = decide_in(&model, "test", &reading, "The room is warm.", &prose, &Tuning::default(), wake);
assert_eq!((decision["read"].clone(), decision["read_refused"][0]["why"].as_str()), (Value::Null, Some("web_address_not_in_front_of_her")), "{decision}");
}