From 536ad6cbec6810f6e939feea12635133a145f849 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 27 Nov 2026 20:56:25 +0100 Subject: [PATCH] Persona T7 fix: a retry note past the cap is recorded as refused, an unparsable retry says why, the own-line boundaries are pinned (Soul s2 N1, N2, N4) Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/interpret.rs | 9 ++++- .../src/projection/interpret/tests.rs | 39 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index db59edf..44706b3 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -368,6 +368,8 @@ pub(crate) enum MemoryRefusal { OverMemories, /// A `resolve` id that names no memory listed to the Interpreter. MemoryUnlisted, + /// A note of the retry's answer past the number of notes sent back: not read, so not kept (`decide_in`). + RetryOverflow, } /// Whether the Interpreter can mend a refused note by saying it again (`decide_in`): its wording, not its count. @@ -383,6 +385,7 @@ fn memory_why(refusal: MemoryRefusal) -> String { MemoryRefusal::Echo => format!("it repeats someone's words from what reached the person or what they read, {ECHO_MIN_WORDS} words or more in a row; no one's line is kept as a memory, so say it in words of its own"), MemoryRefusal::OverMemories => "one answer keeps at most four notes".to_owned(), MemoryRefusal::MemoryUnlisted => "it names no memory listed".to_owned(), + MemoryRefusal::RetryOverflow => "the answer to the retry held more notes than were sent back".to_owned(), } } @@ -796,6 +799,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na } if retried { if room_left == 0 { + memory_refused.push(json!({ "act": "remember", "text": text, "reason": MemoryRefusal::RetryOverflow })); continue; } room_left -= 1; @@ -833,7 +837,10 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na let asking = format!("{prompt}\n\nSome notes in an earlier answer to this were refused:\n{refused_notes}Answer the speech contract again. Only `remember` is read this time: say each refused note you still want kept in words of its own, or leave it out. Everything else in your earlier answer is settled."); let request_id = format!("{segment_id}:{attempt}"); let (usage, second, failed) = match model.ask(&request_id, &tuning.interpreter.model, &asking, Some(SPEECH_SCHEMA)) { - Ok(answer) => (answer.usage, serde_json::from_str::(&answer.text).ok().map(|answer| answer.remember), None), + Ok(answer) => match serde_json::from_str::(&answer.text) { + Ok(second) => (answer.usage, Some(second.remember), None), + Err(_) => (answer.usage, None, Some("the answer is not the speech contract".to_owned())), + }, Err(failed) => (failed.usage, None, Some(failed.reason)), }; let mut call = json!({ "usage": usage, "retry": false, "memory_retry": true }); diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index 9cc4e95..d6f2fff 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -2223,3 +2223,42 @@ fn r19_a_draft_that_copies_a_heard_line_does_not_launder_it_into_a_note() { let decision = answered(&packet, &prose, json!({ "say": [], "gaps": [], "remember": [note(&format!("Meta said: {X1_META_R1}"), &[META])] })); assert_eq!((decision["state"].clone(), decision["memory_refused"][0]["reason"].as_str()), (json!([]), Some("echo")), "{decision}"); } + +/// Soul s2 (own-line-pins-missing; n05 exactly `ECHO_MIN_WORDS` words, n03 a prefix of the joined string): a posted line of +/// exactly eight words is exempt, and a line is exempt only as whole words: `today` does not cut into `todayish`. +#[test] +fn r19_an_eight_word_line_is_exempt_whole_words_only() { + let own = "the welcome lines are ready for newcomers today"; + assert_eq!(span::tokens(own).count(), ECHO_MIN_WORDS); + let heard = format!("Libby, here: {own}. Tell Meta when you have changed it."); + let packet = with_own_line(libby_packet(&[(HER, "Heimdall", &heard, true)]), own); + let carrying = format!("Libby posted that {own}."); + let decision = answered(&packet, "Noted.", json!({ "say": [], "gaps": [], "remember": [note(&carrying, &[HER])] })); + assert_eq!((decision["state"][0]["text"].as_str(), decision.get("memory_refused")), (Some(carrying.as_str()), None), "{decision}"); + let longer = "Heimdall: the welcome lines are ready for newcomers todayish and Meta wants them held."; + let packet = with_own_line(libby_packet(&[(HER, "Heimdall", longer, true)]), own); + let copied = "Heimdall noted welcome lines are ready for newcomers todayish and Meta wants them held."; + let decision = answered(&packet, "Noted.", json!({ "say": [], "gaps": [], "remember": [note(copied, &[HER])] })); + assert_eq!(decision["memory_refused"][0]["reason"].as_str(), Some("echo"), "{decision}"); +} + +/// Soul s2 (cap-drop-unrecorded, retry-parse-fail-no-why): a second-answer note past the number sent back is recorded as +/// refused with its own reason, and a second answer that is not the contract records why on its call. +#[test] +fn r19_a_dropped_retry_note_is_recorded_and_an_unparsable_retry_says_why() { + let packet = libby_packet(&[(META, "Meta", X1_META_R1, true)]); + let accepted = "Libby told Meta she would hold the welcome lines until Heimdall rules."; + let rephrased = "Meta asked Libby to hold the welcome lines and say when they are ready."; + let (decision, _, _) = retry_run( + &packet, + X5_LIBBY_R1, + json!({ "say": [], "gaps": [], "remember": [note(X1_META_R1, &[META]), note(accepted, &[META])] }), + json!({ "say": [], "gaps": [], "remember": [note("Libby promised Meta to wait for Heimdall's ruling on the welcome lines.", &[META]), note(rephrased, &[META])] }), + ); + assert_eq!(decision["memory_refused"][0]["reason"].as_str(), Some("retry_overflow"), "{decision}"); + assert_eq!(decision["memory_refused"][0]["text"].as_str(), Some(rephrased), "{decision}"); + let reply = json!({ "say": [], "gaps": [], "remember": [note(X1_META_R1, &[META])] }).to_string(); + let scripted = Scripted::new(|_| String::new()).interpreting(move |prompt| if prompt.contains("notes in an earlier answer to this were refused") { "not json".to_owned() } else { reply.clone() }); + let decision = decide(&scripted, "test", &packet, "The room is warm.", X5_LIBBY_R1, &Tuning::default()); + assert_eq!((decision["memory_refused"][0]["reason"].as_str(), decision["calls"][1]["failed"].as_str()), (Some("echo"), Some("the answer is not the speech contract")), "{decision}"); +}