From 0a2f2cf2a41b30efa054459a8cbc76ad561992cc Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 21 Nov 2026 02:31:44 +0100 Subject: [PATCH] Persona promises: a promise closed in this conversation stays in her view, marked closed and how Soul's R7 item 3. The exchange carries when the conversation began (her first turn in K26's window). Her view lists, under "Her promises:", every open or blocked promise as before and every promise closed since the conversation began, with how: "Closed: she kept it a few minutes ago." / "she withdrew it" / "Meta released her from it". When the conversation ends they leave. The Interpreter still lists only the open and blocked ones, by id. Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/exchange.rs | 4 +- crates/mind-body/src/projection/select.rs | 46 +++++++++++++------ crates/mind-body/src/projection/simulate.rs | 6 +-- .../src/projection/simulate/tests.rs | 6 +-- crates/mind-body/src/projection/tests.rs | 23 +++++++++- 5 files changed, 61 insertions(+), 24 deletions(-) diff --git a/crates/mind-body/src/projection/exchange.rs b/crates/mind-body/src/projection/exchange.rs index f92fd96..2f5ba69 100644 --- a/crates/mind-body/src/projection/exchange.rs +++ b/crates/mind-body/src/projection/exchange.rs @@ -37,6 +37,8 @@ pub(crate) struct Exchange { pub(crate) lines: Vec, pub(crate) reads: Vec, pub(crate) tried: Vec, + /// When the conversation began: her first turn in it. What she closed since is still listed (Soul's R7). + pub(crate) since: Option>, } /// A read's latest result as her view shows it. @@ -76,7 +78,7 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime, her next = at; } kept.reverse(); - let mut exchange = Exchange::default(); + let mut exchange = Exchange { since: kept.first().map(|(_, at)| *at), ..Exchange::default() }; for (record, at) in &kept { let decision = &record["interpreter"]; for receipt in record["posted"].as_array().into_iter().flatten() { diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index 58eed4c..1ad486c 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -1820,25 +1820,33 @@ fn part_of_day(at: DateTime) -> &'static str { } } -/// Her open promises in her view (map 16.22.1, 16.23.1): every `open` or `blocked` entry of her state's `commitments`, -/// oldest first, whole, with her own words, never withheld and never dropped. A dropped promise is what produced the r6 -/// denials, so past `promises_bytes` every one is still rendered and the overflow is reported. The Interpreter lists -/// them all, by id. +/// Her promises in her view (map 16.22.1, 16.23.1): every `open` or `blocked` entry of her state's `commitments`, oldest +/// first, whole, with her own words, never withheld and never dropped. A dropped promise is what produced the r6 denials, +/// so past `promises_bytes` every one is still rendered and the overflow is reported. A promise closed in this +/// conversation (K26's window) stays listed, marked closed and how, until the conversation ends (Soul's R7). The +/// Interpreter lists the open and blocked ones, by id. fn open_promises(inputs: &Inputs, her: Forms) -> (Vec, String) { + let open = |entry: &Value| matches!(text(entry, &["status"]), "open" | "blocked"); + let conversation = inputs.exchange.and_then(|exchange| exchange.since); + let closed_in_it = |entry: &Value| { + matches!(text(entry, &["status"]), "kept" | "withdrawn" | "released") + && conversation.zip(DateTime::parse_from_rfc3339(text(entry, &["closedAt"])).ok()).is_some_and(|(since, at)| at.with_timezone(&Utc) >= since) + }; let mut entries: Vec<(DateTime, &Value)> = items(inputs.state, &["commitments"]) .iter() - .filter(|entry| matches!(text(entry, &["status"]), "open" | "blocked")) + .filter(|entry| open(entry) || closed_in_it(entry)) .map(|entry| (DateTime::parse_from_rfc3339(text(entry, &["madeAt"])).map_or(inputs.now, |at| at.with_timezone(&Utc)), entry)) .collect(); entries.sort_by_key(|(at, _)| *at); - let promised: Vec = entries + let mut listed = 0; + let shown: Vec = entries .iter() - .enumerate() - .map(|(at, (made, entry))| { + .map(|(made, entry)| { let to = entry.get("to").and_then(Value::as_str).map(str::to_owned); let room = text(entry, &["room"]); + listed += usize::from(open(entry)); Promised { - id: format!("c{}", at + 1), + id: if open(entry) { format!("c{listed}") } else { String::new() }, entry: text(entry, &["id"]).to_owned(), status: text(entry, &["status"]).to_owned(), to_name: to.as_deref().map_or_else(|| "the room".to_owned(), |to| sender_name(to, inputs)), @@ -1850,12 +1858,20 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec, String) { } }) .collect(); - if promised.is_empty() { - return (promised, String::new()); + if shown.is_empty() { + return (Vec::new(), String::new()); } - let lines: Vec = promised + let lines: Vec = shown .iter() .map(|promise| { + // Closed in this conversation, and how. + let closed_at = || promise.held["closedAt"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map_or_else(String::new, |at| format!(" {}", coarse(at.with_timezone(&Utc), inputs.now))); + let closed = match promise.status.as_str() { + "kept" => format!(" Closed: {} kept it{}.", her.subj, closed_at()), + "withdrawn" => format!(" Closed: {} withdrew it{}.", her.subj, closed_at()), + "released" => format!(" Closed: {} released {} from it{}.", promise.to_name, her.obj, closed_at()), + _ => String::new(), + }; // Blocked by a read that found nothing (map 16.24.3), or by having no way to do it. let blocked = match (promise.status.as_str(), promise.held["blockedBy"]["act"].as_str()) { ("blocked", Some("read")) => format!(" {} looked and could not find it.", her.cap_subj), @@ -1864,11 +1880,11 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec, String) { }; // Each time she said it again, verbatim (map 16.24.2). let again: String = promise.held["reaffirmed"].as_array().into_iter().flatten().map(|said| format!(" Said again {}: {}.", said["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map_or_else(|| "since".to_owned(), |at| coarse(at.with_timezone(&Utc), inputs.now)), spoken(said["words"].as_str().unwrap_or_default()))).collect(); - format!("- to {}, {}, {}, {} promise: {}.{again}{blocked}", promise.to_name, coarse(promise.made, inputs.now), promise.place, her.poss, spoken(&promise.words)) + format!("- to {}, {}, {}, {} promise: {}.{again}{blocked}{closed}", promise.to_name, coarse(promise.made, inputs.now), promise.place, her.poss, spoken(&promise.words)) }) .collect(); - let block = format!("{} open promises:\n{}", capitalized(her.poss), lines.join("\n")); - (promised, block) + let block = format!("{} promises:\n{}", capitalized(her.poss), lines.join("\n")); + (shown.into_iter().filter(|promise| !promise.id.is_empty()).collect(), block) } diff --git a/crates/mind-body/src/projection/simulate.rs b/crates/mind-body/src/projection/simulate.rs index f29a1ea..2ce19e8 100644 --- a/crates/mind-body/src/projection/simulate.rs +++ b/crates/mind-body/src/projection/simulate.rs @@ -692,13 +692,13 @@ fn transcript_line(line: &Value) -> String { format!("- r{} {} **{who}**{woke}: {}", line["round"], line["room"].as_str().unwrap_or_default(), one_line(line["says"].as_str().unwrap_or_default())) } -/// What a turn did to her promises, as the report shows it (B4): the open-promises section her packet showed her, the +/// What a turn did to her promises, as the report shows it (B4): the promises section her packet showed her, the /// state changes the Interpreter proposed, and what the commit opened and refused. fn promises_markdown(out: &mut String, turn: &Value) { let view = turn["report"]["packet"]["in_view"].as_str().unwrap_or_default(); - let section: Vec<&str> = view.lines().skip_while(|line| !line.ends_with(" open promises:")).take_while(|line| line.ends_with(" open promises:") || line.starts_with("- ")).collect(); + let section: Vec<&str> = view.lines().skip_while(|line| !line.ends_with(" promises:")).take_while(|line| line.ends_with(" promises:") || line.starts_with("- ")).collect(); if !section.is_empty() { - let _ = writeln!(out, "Open promises, as her packet showed them:\n\n````text\n{}\n````\n", section.join("\n")); + let _ = writeln!(out, "Promises, as her packet showed them:\n\n````text\n{}\n````\n", section.join("\n")); } let proposed = turn["report"]["renders"][0]["interpreter"]["state"].as_array().cloned().unwrap_or_default(); if !proposed.is_empty() { diff --git a/crates/mind-body/src/projection/simulate/tests.rs b/crates/mind-body/src/projection/simulate/tests.rs index 59f2908..e404604 100644 --- a/crates/mind-body/src/projection/simulate/tests.rs +++ b/crates/mind-body/src/projection/simulate/tests.rs @@ -630,7 +630,7 @@ fn k22_a_promise_persists_across_silent_turns_until_the_person_releases_it() { let opened = &his[0]["committed"]["opened"][0]; assert_eq!((opened["status"].as_str(), opened["to"].as_str(), opened["words"].as_str()), (Some("blocked"), Some("@meta:gamecult.org"), Some("I'll send the render tonight.")), "{}", his[0]["committed"]); let context = |turn: &Value| turn["report"]["packet"]["in_view"].as_str().unwrap().to_owned(); - let shown = "His open promises:\n- to Meta"; + let shown = "His promises:\n- to Meta"; assert_eq!((his[1]["outcome"].as_str(), context(his[1]).contains(shown), context(his[2]).contains(shown)), (Some("silent"), true, true), "it stays in front of him through a silent turn: {}", context(his[1])); assert!(context(his[1]).contains("his promise: \"I'll send the render tonight.\". He has no way to do it yet."), "{}", context(his[1])); assert_eq!(his[2]["committed"]["closed"][0]["entry"]["status"], "released", "{}", his[2]["committed"]); @@ -696,7 +696,7 @@ says = "good afternoon, everyone" fn b4_a_turns_details_show_her_promises_the_proposals_and_the_commit() { let turn = json!({ "report": { - "packet": { "in_view": "His open promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n\nHis domain, as he looks at it now:" }, + "packet": { "in_view": "His promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n\nHis domain, as he looks at it now:" }, "renders": [{ "interpreter": { "state": [{ "kind": "promise_close", "promise": "c1", "how": "withdrawn", "evidence": { "draft": 1 } }] } }] }, "committed": { @@ -707,7 +707,7 @@ fn b4_a_turns_details_show_her_promises_the_proposals_and_the_commit() { let mut out = String::new(); promises_markdown(&mut out, &turn); for part in [ - "Open promises, as her packet showed them:\n\n````text\nHis open promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n````", + "Promises, as her packet showed them:\n\n````text\nHis promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n````", "State proposed:\n\n- `{", "\"how\":\"withdrawn\"", "- opened `c-r1-t2-1` (blocked, to @meta:gamecult.org): send the render tonight", diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index cb43493..086d5fa 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -2598,7 +2598,7 @@ fn promising(entries: usize) -> Value { #[test] fn k22_her_open_promises_are_in_her_view_whole_and_the_interpreters_list() { let packet = packet_of(TurnKind::Chat, &promising(1), &chat_room(), &History::default(), 1); - let line = "Her open promises:\n- to Meta, the operator, Tuesday afternoon, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet."; + let line = "Her promises:\n- to Meta, the operator, Tuesday afternoon, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet."; assert!(packet.in_view.starts_with(line) && !packet.in_view.contains("KEPT-ONE"), "{}", packet.in_view); assert!(!packet.context.contains("open promises") && !narrate::projector_prompt(&packet, &Tuning::default()).contains("render tonight"), "the Projector gets nothing of them"); assert_eq!((packet.promises.len(), packet.promises[0].id.as_str(), packet.promises[0].entry.as_str()), (1, "c1", "c-r1-t1-0")); @@ -2607,7 +2607,7 @@ fn k22_her_open_promises_are_in_her_view_whole_and_the_interpreters_list() { let persona = narrate::persona_prompt(&packet, "The room is warm.", &Tuning::default()); assert!(persona.contains(line) && !persona.contains("c1") && !persona.contains("c-r1-t1-0"), "in her view, with no id: {persona}"); // A beat shows them too: they are facts about her, not about the turn. - assert!(packet_of(TurnKind::Beat, &promising(1), &chat_room(), &History::default(), 1).in_view.contains("Her open promises:")); + assert!(packet_of(TurnKind::Beat, &promising(1), &chat_room(), &History::default(), 1).in_view.contains("Her promises:")); // Past the guard: every one shown, oldest first, none dropped, and the overflow reported. let mut tight = Tuning::default(); tight.select.promises_bytes = 300; @@ -2793,3 +2793,22 @@ fn r7_no_clock_time_appears_anywhere_in_the_persona_prompt() { assert_eq!(select::coarse(now() - chrono::Duration::minutes(minutes), now()), words, "{minutes} min before"); } } + +/// Soul's R7: a promise closed in this conversation stays in her view, marked closed and how, while the conversation +/// lasts; one closed before it began is gone, and the Interpreter never lists a closed one. +#[test] +fn r7_a_promise_closed_in_this_conversation_stays_in_view_marked_closed() { + let tuning = Tuning::default(); + let mut with = promising(1); + with["commitments"][1]["closedAt"] = json!((now() - chrono::Duration::minutes(5)).to_rfc3339()); + with["commitments"].as_array_mut().unwrap().push(json!({ "id": "c-old", "to": OPERATOR, "room": "#swarm:gamecult.org", "event": "7", "madeAt": (now() - chrono::Duration::days(1)).to_rfc3339(), "words": "WITHDRAWN-LONG-AGO", "status": "withdrawn", "closedAt": (now() - chrono::Duration::hours(2)).to_rfc3339(), "closedBy": null, "extensions": {} })); + let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room()); + let exchange = crate::projection::exchange::Exchange { since: Some(now() - chrono::Duration::minutes(20)), ..Default::default() }; + let inputs = |exchange| Inputs { kind: TurnKind::Chat, state: &with, room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: None, exchange }; + let packet = select(&inputs(Some(&exchange)), &tuning); + assert!(packet.in_view.contains("her promise: \"KEPT-ONE\". Closed: she kept it a few minutes ago."), "{}", packet.in_view); + assert!(!packet.in_view.contains("WITHDRAWN-LONG-AGO"), "closed before the conversation began: gone"); + assert_eq!(packet.promises.iter().map(|promise| promise.id.as_str()).collect::>(), ["c1"], "the Interpreter lists only what is open"); + assert!(!interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning).contains("KEPT-ONE")); + assert!(!select(&inputs(None), &tuning).in_view.contains("KEPT-ONE"), "no conversation, no closed promise"); +}