diff --git a/crates/mind-body/src/projection/exchange.rs b/crates/mind-body/src/projection/exchange.rs index 07a22fa..f92fd96 100644 --- a/crates/mind-body/src/projection/exchange.rs +++ b/crates/mind-body/src/projection/exchange.rs @@ -17,7 +17,7 @@ use serde_json::Value; use super::domain::floor_minute; use super::read::ReadRequest; -use super::select::{Forms, capitalized, spoken}; +use super::select::{Forms, capitalized, coarse, spoken}; /// How long a pause ends a conversation (Q-G (a)): her turns in a room belong to one conversation while each is within /// this many minutes of the next. @@ -59,10 +59,6 @@ fn at_of(record: &Value) -> Option> { record["interpreter"]["at_ms"].as_i64().and_then(DateTime::from_timestamp_millis) } -fn time_of(at: DateTime, now: DateTime) -> String { - if at.date_naive() == now.date_naive() { at.format("%H:%M UTC").to_string() } else { at.format("%A %-d %B, %H:%M UTC").to_string() } -} - /// Her side of the conversation in `room` as `records` (her turn records, oldest first) hold it, at `now`. pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime, her: Forms) -> Exchange { // Her turns in this room, newest first, while each is within the window of the one after it (now, for the newest). @@ -96,7 +92,7 @@ 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("")) }); + exchange.lines.push(Did { at: *at, text: format!("- {}{reply}: {}{}", coarse(*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 }; @@ -112,7 +108,7 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime, her 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(Shown { at: *at, key: request.normal(), text: format!("{} read {what} ({}):\n{fence}\n{text}\n{fence}", capitalized(her.subj), time_of(*at, now)) }); + exchange.reads.push(Shown { at: *at, key: request.normal(), text: format!("{} read {what} ({}):\n{fence}\n{text}\n{fence}", capitalized(her.subj), coarse(*at, now)) }); } } exchange @@ -130,7 +126,7 @@ pub(crate) fn render(exchange: &Exchange, her: Forms, budget: usize, now: DateTi if lines.is_empty() && reads.is_empty() { return String::new(); } - let since = if shrunk { format!(" since {}", time_of(start, now)) } else { String::new() }; + let since = if shrunk { format!(" since {}", coarse(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().map(|did| did.text.clone())).chain(reads.iter().map(|shown| shown.text.clone())).collect::>().join("\n"); if block.len() <= budget { diff --git a/crates/mind-body/src/projection/exchange/tests.rs b/crates/mind-body/src/projection/exchange/tests.rs index e086f42..3ceb83b 100644 --- a/crates/mind-body/src/projection/exchange/tests.rs +++ b/crates/mind-body/src/projection/exchange/tests.rs @@ -37,7 +37,7 @@ fn k26_her_side_of_the_conversation_is_her_lines_and_her_reads_while_it_lasts() ]; let exchange = exchange_of(&records, MINDS, now(), her()); 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_eq!(view, "What he has said and read in this conversation:\n- about an hour ago, replying to Meta: \"The knee bends first, I think.\" (he added: \"Checked: it does.\")\nHe read GameCult/Bifrost on the forge (about half an hour ago):\n````\nNEW Bifrost list\n````\nHe read GameCult/Lodur#12 on the forge (about half an hour ago):\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"); 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"); @@ -52,8 +52,8 @@ 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()); - assert_eq!(view, "What he has said and read in this conversation since 14:21 UTC:\n- 14:40 UTC: \"SECOND line of mine.\""); + let view = render(&exchange, her(), 140, now()); + assert_eq!(view, "What he has said and read in this conversation since about half an hour ago:\n- about half an hour ago: \"SECOND line of mine.\""); assert!(render(&exchange, her(), 20, now()).is_empty(), "not even the newest fits: none"); } diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 724cec2..39ed843 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -440,7 +440,7 @@ pub(crate) fn speech_prompt_in(packet: &Packet, narration: &str, prose: &str, tu .map(|promise| { let to = promise.to.as_deref().map_or_else(String::new, |to| format!(" ({to})")); let status = if promise.status == "blocked" { format!("which {} {} no way to do", her.subj, her.has) } else { "open".to_owned() }; - format!("- {} \u{2014} to {}{to}, {status}, made {} {}: {}\n", promise.id, promise.to_name, promise.made, promise.place, spoken(&promise.words)) + format!("- {} \u{2014} to {}{to}, {status}, made {} {}: {}\n", promise.id, promise.to_name, promise.made.format("%Y-%m-%d %H:%M UTC"), promise.place, spoken(&promise.words)) }) .collect(); if promises.is_empty() { diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index 005ee6e..58eed4c 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -29,7 +29,7 @@ use std::collections::BTreeSet; use std::fmt::Write as _; -use chrono::{DateTime, Utc}; +use chrono::{DateTime, Timelike, Utc}; use serde::Serialize; use serde_json::Value; use unicode_segmentation::UnicodeSegmentation; @@ -399,9 +399,10 @@ pub(crate) struct Promised { /// Whom to: a Matrix id, none for the room; and as the packet names them. pub to: Option, pub to_name: String, - /// Where she made it, as the packet says it ("in #minds:gamecult.org", "in a direct message"), and how long ago. + /// Where she made it, as the packet says it ("in #minds:gamecult.org", "in a direct message"), and when: exact, for + /// the Interpreter; her view says it coarsely (`coarse`). pub place: String, - pub made: String, + pub made: DateTime, pub words: String, /// The entry whole, as her state held it when the packet was built: the turn's starting copy, which the commit /// compares the entry against, so an outside put wins on any field it changed (4.4, B6). Never shown to a model. @@ -826,7 +827,7 @@ fn sender_name(sender: &str, inputs: &Inputs) -> String { /// A reply as every line renders it (map 16.20.8 (D), K20): the line it answers, above it, by who said it and in the words /// the mouth quoted (`> {other}: "…"`), and `, replying to {other}` after the speaker's name. Both empty for a line that /// replies to nothing. When the page lists the answered line whole (`listed`), the reply names it by who and when -/// (`, replying to a line shown here ({other}, 15 min ago)`) and quotes it no second time, wherever the name is no longer +/// (`, replying to a line shown here ({other}, a few minutes ago)`) and quotes it no second time, wherever the name is no longer /// than the quote: a selection made on quoted lines then still fits. fn reply_parts(line: &RoomLine, inputs: &Inputs, listed: &[&RoomLine]) -> (String, String) { let Some(replied) = &line.reply else { @@ -855,14 +856,9 @@ fn excerpt(replied: &Replied) -> String { } } -/// When a listed line was said, as the page says it of its lines: a beat's in hours, a chat turn's new lines "just now", -/// its earlier ones in minutes. +/// When a listed line was said, as she reads it: a chat turn's new lines "just now", every other one coarsely (`coarse`). fn when(line: &RoomLine, inputs: &Inputs) -> String { - match inputs.kind { - TurnKind::Beat => format!("{} h ago", hours(inputs.now, line.at_ms)), - _ if inputs.room.messages.iter().any(|message| std::ptr::eq(message, line)) => "just now".to_owned(), - _ => format!("{} min ago", minutes(inputs.now, line.at_ms)), - } + if inputs.kind != TurnKind::Beat && inputs.room.messages.iter().any(|message| std::ptr::eq(message, line)) { "just now".to_owned() } else { coarse_ms(inputs.now, line.at_ms) } } /// The words of a line she was shown: its own, and the words it quotes of another's line when it is a reply to someone @@ -1149,7 +1145,7 @@ fn earlier_lines<'a>(inputs: &'a Inputs, listed: &[&RoomLine]) -> Vec<(String, & .map(|line| { let name = if line.sender == inputs.people.own_sender && !own.is_empty() { clip(&one_line(own), NAME_BYTES) } else { name_of(line, inputs) }; let (above, replying) = reply_parts(line, inputs, listed); - (format!("{above}{name}{replying}, {} min ago: {}", minutes(inputs.now, line.at_ms), spoken(&line.text)), line) + (format!("{above}{name}{replying}, {}: {}", coarse_ms(inputs.now, line.at_ms), spoken(&line.text)), line) }) .collect() } @@ -1170,10 +1166,6 @@ fn newest_that_fit(lines: &[String], budget: usize) -> (Vec, usize) { (kept, dropped) } -fn hours(now: DateTime, at_ms: u64) -> i64 { - let at = i64::try_from(at_ms).ok().and_then(DateTime::::from_timestamp_millis).unwrap_or(now); - (now - at).num_hours().max(0) -} /// A beat: nothing addressed her; when she last heard from each person she is bound to (the relatedness cue, most /// recently heard first, in at most two thirds of the cap, a note counting any left out); then the newest lines of her @@ -1188,7 +1180,7 @@ fn beat_stimulus<'a>(inputs: &'a Inputs, tuning: &Tuning, listed: &[&RoomLine]) .iter() .map(|line| { let (above, replying) = reply_parts(line, inputs, listed); - format!("{above}- {}{replying} in {}, {} h ago: {}", name_of(line, inputs), line.room, hours(inputs.now, line.at_ms), spoken(&words(line))) + format!("{above}- {}{replying} in {}, {}: {}", name_of(line, inputs), line.room, coarse_ms(inputs.now, line.at_ms), spoken(&words(line))) }) .collect(); let (section, shown) = newest_section(&format!("Lately in {} rooms:", her.poss), &lines, cap.saturating_sub(out.out.len() + 2)); @@ -1217,7 +1209,7 @@ fn beat_contacts(inputs: &Inputs, tuning: &Tuning) -> String { let heard = inputs.room.tail.iter().map(|line| (line.sender.as_str(), line.at_ms)).chain(inputs.room.last_heard.iter().map(|(sender, at)| (sender.as_str(), *at))); let last = heard.filter(|(sender, _)| inputs.people.person_of(sender) == person).map(|(_, at)| at).max(); contacts.push((last, match last { - Some(at) => format!("- last heard from {label} {} h ago", hours(inputs.now, at)), + Some(at) => format!("- last heard from {label} {}", coarse_ms(inputs.now, at)), None => format!("- nothing from {label} in {} rooms lately", forms(inputs.state).poss), })); } @@ -1247,7 +1239,7 @@ fn beat_heard<'a>(inputs: &'a Inputs, tuning: &Tuning, listed: &[&RoomLine]) -> .iter() .map(|line| { let (above, replying) = reply_parts(line, inputs, listed); - format!("{above}{}{replying}, in {}, {} h ago: {}", name_of(line, inputs), line.room, hours(inputs.now, line.at_ms), spoken(&line.text)) + format!("{above}{}{replying}, in {}, {}: {}", name_of(line, inputs), line.room, coarse_ms(inputs.now, line.at_ms), spoken(&line.text)) }) .collect(); let (kept, dropped) = newest_that_fit(&lines, tuning.select.heard_bytes); @@ -1536,7 +1528,7 @@ fn conversation(inputs: &Inputs, tuning: &Tuning) -> Conversation { speaking.push(format!("{} asked the room a question, and {} answered it", label_of(window[asked], inputs), answered.join("; "))); } if let Some(line) = window.iter().rev().find(|line| !is_mind(inputs, &line.sender)) { - speaking.push(format!("{} last spoke {} min ago", label_of(line, inputs), minutes(inputs.now, line.at_ms))); + speaking.push(format!("{} last spoke {}", label_of(line, inputs), coarse_ms(inputs.now, line.at_ms))); } let minds_in_a_row = window.iter().rev().take_while(|line| is_mind(inputs, &line.sender)).count(); if minds_in_a_row >= 2 { @@ -1668,10 +1660,6 @@ fn sentence(part: &str) -> String { /// The pronouns of a person nobody listed. const UNKNOWN_PRONOUNS: &str = "they/them"; -fn minutes(now: DateTime, at_ms: u64) -> i64 { - let at = i64::try_from(at_ms).ok().and_then(DateTime::::from_timestamp_millis).unwrap_or(now); - (now - at).num_minutes().max(0) -} // --------------------------------------------------------------------------------------------- // Her body. @@ -1793,14 +1781,42 @@ fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] { } /// How long ago a promise was made, in words. -fn ago(now: DateTime, at: DateTime) -> String { - let minutes = (now - at).num_minutes().max(0); - match minutes { - 0 => "just now".to_owned(), - 1..60 => format!("{minutes} min ago"), - 60..1440 => format!("{} h ago", minutes / 60), - 1440..2880 => "a day ago".to_owned(), - _ => format!("{} days ago", minutes / 1440), +/// A moment as she reads it (Soul's R7 timestamp ledger): coarse and relative, never a clock time, so nothing she reads +/// gives her a time to recite. "just now", "a few minutes ago", "about half an hour ago", "about an hour ago", "earlier +/// this afternoon", "this morning", "last night", "yesterday evening", "Thursday afternoon", "13 November". Exact times +/// stay in the records and in the Interpreter's prompt. +pub(crate) fn coarse(at: DateTime, now: DateTime) -> String { + let part = part_of_day(at); + match (now - at).num_minutes().max(0) { + 0..2 => "just now".to_owned(), + 2..15 => "a few minutes ago".to_owned(), + 15..45 => "about half an hour ago".to_owned(), + 45..90 => "about an hour ago".to_owned(), + _ => match (now.date_naive() - at.date_naive()).num_days() { + ..=0 if at.hour() < 5 && now.hour() >= 5 => "last night".to_owned(), + ..=0 if part == part_of_day(now) => if part == "night" { "earlier tonight".to_owned() } else { format!("earlier this {part}") }, + ..=0 => format!("this {part}"), + 1 if at.hour() >= 21 => "late yesterday evening".to_owned(), + 1 if at.hour() < 5 => "early yesterday morning".to_owned(), + 1 => format!("yesterday {part}"), + 2..7 => format!("{} {part}", at.format("%A")), + _ => at.format("%-d %B").to_string(), + }, + } +} + +/// `coarse` of a moment in Unix milliseconds. +fn coarse_ms(now: DateTime, at_ms: u64) -> String { + coarse(i64::try_from(at_ms).ok().and_then(DateTime::::from_timestamp_millis).unwrap_or(now), now) +} + +/// The part of the day a moment falls in, by UTC: morning, afternoon, evening or night. +fn part_of_day(at: DateTime) -> &'static str { + match at.hour() { + 5..12 => "morning", + 12..17 => "afternoon", + 17..21 => "evening", + _ => "night", } } @@ -1828,7 +1844,7 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec, String) { to_name: to.as_deref().map_or_else(|| "the room".to_owned(), |to| sender_name(to, inputs)), to, place: if room_kind(inputs, room) == RoomKind::Direct { "in a direct message".to_owned() } else { format!("in {room}") }, - made: ago(inputs.now, *made), + made: *made, words: text(entry, &["words"]).to_owned(), held: (*entry).clone(), } @@ -1847,23 +1863,14 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec, String) { _ => String::new(), }; // 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| ago(inputs.now, at.with_timezone(&Utc))), spoken(said["words"].as_str().unwrap_or_default()))).collect(); - format!("- to {}, {}, {}, {} promise: {}.{again}{blocked}", promise.to_name, promise.made, promise.place, her.poss, spoken(&promise.words)) + 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)) }) .collect(); let block = format!("{} open promises:\n{}", capitalized(her.poss), lines.join("\n")); (promised, block) } -/// A moment in words from where `now` stands: "14:00 UTC today", "yesterday, 21:30 UTC", "Tuesday 17 November, 09:00 UTC". -fn time_words(at: DateTime, now: DateTime) -> String { - let time = at.format("%H:%M UTC"); - match (now.date_naive() - at.date_naive()).num_days() { - ..=0 => format!("{time} today"), - 1 => format!("yesterday, {time}"), - _ => format!("{}, {time}", at.format("%A %-d %B")), - } -} /// Her domain in her view (map 16.23.1, 16.23.3, 16.23.5): every item of the window, whole, newest first, under headings /// that state the window: `New since {she} last looked ({time}):` for what came after her last wake, `Earlier, since @@ -1892,13 +1899,13 @@ fn domain_view(inputs: &Inputs, her: Forms, room: usize) -> (Vec, St Some(look) if start <= look => { let (new, earlier): (Vec<&&Item>, Vec<&&Item>) = kept.iter().partition(|item| item.at > look); if !new.is_empty() { - parts.push(format!("New since {} last looked ({}):\n{}", her.subj, time_words(look, digest.now), lines(&new))); + parts.push(format!("New since {} last looked ({}):\n{}", her.subj, coarse(look, digest.now), lines(&new))); } if !earlier.is_empty() { - parts.push(format!("Earlier, since {}:\n{}", time_words(start, digest.now), lines(&earlier))); + parts.push(format!("Earlier, since {}:\n{}", coarse(start, digest.now), lines(&earlier))); } } - _ => parts.push(format!("New since {}:\n{}", time_words(start, digest.now), lines(&kept.iter().collect::>()))), + _ => parts.push(format!("New since {}:\n{}", coarse(start, digest.now), lines(&kept.iter().collect::>()))), } let block = parts.join("\n"); if block.len() <= room { @@ -2084,7 +2091,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { let (promises, promises_view) = open_promises(inputs, her); let present_ids: BTreeSet = present.iter().map(|(id, _)| id.clone()).collect(); let bonds = items(inputs.state, &["affect", "socialBonds"]); - context.force(Section::Here, format!("- now: {}", inputs.now.format("%A %-d %B, %H:%M UTC"))); + context.force(Section::Here, format!("- now: {}, {}", inputs.now.format("%A %-d %B"), part_of_day(inputs.now))); if let Some(mood) = mood_line(inputs.state, inputs.history.previous.as_ref()) { context.force(Section::Here, mood); } diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index cd37f45..c2fd521 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -2598,12 +2598,12 @@ 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, 2 days ago, 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 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."; 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")); let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &Tuning::default()); - assert!(speech.contains("Her open promises, as id \u{2014} to whom: words:\n- c1 \u{2014} to Meta, the operator (@meta:gamecult.org), which she has no way to do, made 2 days ago in #swarm:gamecult.org: \"I'll send the render tonight, part 0.\""), "{speech}"); + assert!(speech.contains("Her open promises, as id \u{2014} to whom: words:\n- c1 \u{2014} to Meta, the operator (@meta:gamecult.org), which she has no way to do, made 2026-11-17 14:05 UTC in #swarm:gamecult.org: \"I'll send the render tonight, part 0.\""), "{speech}"); 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. @@ -2671,10 +2671,9 @@ fn k25_her_domain_is_in_her_view_whole_in_a_stated_window_that_shrinks_and_never let shown = domain_section(&packet); let texts: Vec = digest.items.iter().map(|item| item.text.clone()).collect(); let look = now() - chrono::Duration::minutes(270); - let earlier_start = now() - chrono::Duration::days(2); - let mut expected = vec![format!("New since she last looked ({} today):", look.format("%H:%M UTC"))]; + let mut expected = vec!["New since she last looked (this morning):".to_owned()]; expected.extend(texts[..4].iter().cloned()); - expected.push(format!("Earlier, since {}:", earlier_start.format("%A %-d %B, %H:%M UTC"))); + expected.push("Earlier, since Tuesday afternoon:".to_owned()); expected.extend(texts[4..].iter().cloned()); assert_eq!(shown, expected, "{}", packet.in_view); assert!(!packet.context.contains("GameCult/Repo") && !narrate::projector_prompt(&packet, &tuning).contains("Change 1"), "the Projector gets nothing of it"); @@ -2691,7 +2690,7 @@ fn k25_her_domain_is_in_her_view_whole_in_a_stated_window_that_shrinks_and_never let shown = domain_section(&bound); let start = DateTime::parse_from_rfc3339(bound.domain_shown.since.as_deref().unwrap()).unwrap().with_timezone(&Utc); let inside: Vec = digest.items.iter().filter(|item| item.at >= start).map(|item| item.text.clone()).collect(); - assert!(start > look && shown[0] == format!("New since {} today:", start.format("%H:%M UTC")) && shown[1..] == inside[..] && !inside.is_empty(), "{shown:?}"); + assert!(start > look && shown[0] == "New since this morning:" && shown[1..] == inside[..] && !inside.is_empty(), "{shown:?}"); assert_eq!(bound.domain_shown.left_out, 9 - inside.len()); assert_eq!(bound.domain.len(), 9, "every item fetched still resolves for the Interpreter"); @@ -2755,7 +2754,7 @@ fn k27_her_view_shows_a_reaffirmed_promise_once() { let mut with = promising(1); with["commitments"][0]["reaffirmed"] = json!([{ "at": (now() - chrono::Duration::hours(3)).to_rfc3339(), "event": "11", "words": "I'll send the render tonight, promise." }]); let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1); - assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\". Said again 3 h ago: \"I'll send the render tonight, promise.\". She has no way to do it yet."), "{}", packet.in_view); + assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\". Said again this morning: \"I'll send the render tonight, promise.\". She has no way to do it yet."), "{}", packet.in_view); assert_eq!(packet.in_view.matches("render tonight, part 0").count(), 1); } @@ -2767,3 +2766,30 @@ fn k28_her_view_says_she_looked_and_could_not_find_it() { let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1); assert!(packet.in_view.contains("\"I'll send the render tonight, part 0.\". She looked and could not find it."), "{}", packet.in_view); } + +/// Whether `text` holds a clock time: a digit, a colon, two digits ("15:10", "9:05"). +fn has_clock_time(text: &str) -> bool { + text.as_bytes().windows(4).any(|w| w[0].is_ascii_digit() && w[1] == b':' && w[2].is_ascii_digit() && w[3].is_ascii_digit()) +} + +/// Soul's R7 timestamp ledger: nothing she reads carries a clock time, so she has none to recite. Her promises (made, +/// said again), her domain's headings, the room's lines and the hour itself are coarse and relative; the Interpreter's +/// prompt keeps the exact time. +#[test] +fn r7_no_clock_time_appears_anywhere_in_the_persona_prompt() { + let tuning = Tuning::default(); + let mut with = promising(2); + with["commitments"][1]["reaffirmed"] = json!([{ "at": (now() - chrono::Duration::minutes(40)).to_rfc3339(), "event": "11", "words": "Still on it." }]); + let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room()); + let digest = nine(); + let inputs = 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: Some(&digest), exchange: None }; + let packet = select(&inputs, &tuning); + let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning); + assert!(persona.contains("Said again about half an hour ago: \"Still on it.\"") && persona.contains("New since she last looked (this morning):"), "{persona}"); + assert!(!has_clock_time(&persona), "{persona}"); + assert!(!has_clock_time(&narrate::projector_prompt(&packet, &tuning)), "nor in the narration she reads"); + assert!(interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning).contains("made 2026-11-17 14:05 UTC"), "the Interpreter keeps the exact time"); + for (minutes, words) in [(0, "just now"), (5, "a few minutes ago"), (30, "about half an hour ago"), (60, "about an hour ago"), (120, "earlier this afternoon"), (300, "this morning"), (60 * 13, "last night"), (60 * 20, "yesterday evening"), (60 * 17, "late yesterday evening"), (60 * 24 * 3, "Monday afternoon"), (60 * 24 * 9, "10 November")] { + assert_eq!(select::coarse(now() - chrono::Duration::minutes(minutes), now()), words, "{minutes} min before"); + } +}