Speech is whole consecutive sentences of her prose; private items are named to the Interpreter and refused in code; echo needs 8 words and 80% overlap (Soul R1, R4, R5, R8, R9)

- Every cited span starts and ends on a UAX#29 sentence boundary; the spans of one line are consecutive sentences, and the line is that unbroken run of her prose. A quotation's inside is segmented as a text of its own, so quoted speech stays sayable. She cannot say half a sentence.
- The prompt lists what she knows privately and allows plain speech of a private matter only to its person, in a DM with exactly them. Code refuses a line that shares a run of three words with a listed item.
- Tests: Soul's Q1a-Q1d refused, Q3d refused on a beat, Q5d refused in a DM with Libby, R9 said, P3 still refused; Hands' "Fine," + "winter" test rewritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 06:01:11 +01:00
commit f7decde001
3 changed files with 246 additions and 60 deletions

View file

@ -42,8 +42,8 @@ impl Scripted {
}
/// The recorded Interpreter of the tests: each double-quoted span of her prose is a line she says, citing itself,
/// mentioning no one. A test double that keeps the tests' prose readable, not the speech rule: quotation marks mean
/// nothing to code, and the live Interpreter is a model.
/// mentioning no one. A test double that keeps the tests' prose readable, not the speech rule: to code a quotation is
/// only a text whose sentences are whole, and the live Interpreter is a model.
pub(crate) fn quoted_lines(prompt: &str) -> String {
let prose = prompt.split("Her prose:\n").nth(1).unwrap_or_default();
let say: Vec<Value> = prose.split('"').enumerate().filter(|(at, part)| at % 2 == 1 && !part.trim().is_empty()).map(|(_, part)| json!({ "spans": [part], "mentions": [], "reply_to": null })).collect();

View file

@ -4,18 +4,24 @@
//! The Persona writes her thought, and when she means to say something she writes the words she would type. The
//! Interpreter decides whether she says them now: it answers with zero or more lines, each a list of spans of her prose
//! cited verbatim, with the people she addresses (Matrix mentions and a reply target, as structured fields). Code builds
//! each line, never the model: the line is its spans, located in her prose in order by Ghostlight's
//! `SourceSpan::locate`, joined with one space. So a line is always her own words verbatim. What this gives up: indirect
//! speech ("I'll tell her I'm fine" says nothing) and any paraphrase by the Interpreter.
//! each line, never the model: each span is located in her prose by Ghostlight's `SourceSpan::locate` and must be whole
//! sentences (UAX #29 sentence segmentation, the Unicode family `locate`'s word boundaries come from), and the spans of
//! one line must be consecutive sentences; the line is that one unbroken run of her prose. A quotation's inside is
//! segmented as a text of its own, so a quoted sentence is whole. So a line is always whole sentences of her own,
//! verbatim and in their order: no stitching, no dropped negation, no condition lifted off its clause. What this gives
//! up: indirect speech ("I'll tell her I'm fine" says nothing), any paraphrase by the Interpreter, and half a sentence:
//! she says a sentence whole or not at all.
//!
//! Code keeps a line only when every span locates in her prose, in order; drops a line that is mostly one long run of
//! the words she heard (an echo, measured on message bodies alone); keeps at most `MAX_LINES` distinct lines; and keeps
//! a mention or a reply target only for someone this packet showed her (`Packet::people`). She speaks only in the turn's
//! room. Every refusal and drop is reported. Nothing here posts: the commit (C3c) will.
//! Code keeps a line only when it is built so; drops an echo (at least `ECHO_MIN_WORDS` words, at least `ECHO_OVERLAP`
//! of its word trigrams in the bodies the stimulus quoted to her); drops a line that shares a run of three words with a
//! private item the packet showed her as known privately (`Packet::private`); keeps at most `MAX_LINES` distinct lines;
//! and keeps a mention or a reply target only for someone this packet showed her (`Packet::people`). She speaks only in
//! the turn's room. Every refusal and drop is reported. Nothing here posts: the commit (C3c) will.
use ghostlight_persona_projection::SourceSpan;
use serde::Deserialize;
use serde_json::{Value, json};
use unicode_segmentation::UnicodeSegmentation;
use super::narrate::{Model, heard_overlap, lived_stream};
use super::select::Packet;
@ -23,21 +29,22 @@ use super::tuning::Tuning;
/// The most lines she says in one turn.
pub(crate) const MAX_LINES: usize = 2;
/// A line of at least this many words whose word trigrams are mostly what she heard is an echo, not her speech.
const ECHO_MIN_WORDS: usize = 4;
const ECHO_OVERLAP: f64 = 0.5;
/// A line of at least this many words whose word trigrams are at least this share of what she heard is an echo, not
/// her speech.
const ECHO_MIN_WORDS: usize = 8;
const ECHO_OVERLAP: f64 = 0.8;
/// What to say, where, to whom, and the gaps: Huginn's chat Interpreter, beside nothing of Ghostlight's but its span rule.
const SPEECH_PROMPT: &str = "You decide what one person says aloud in a chat room this turn, from her own prose. You never write her words: you cite them.
Below are who she is, the room and who is in it, what reached her, her lived moment, and her prose. Decide which words of her prose she chooses to say aloud now, in this room. A line is speech only when her prose shows her choosing to say it now. Wondering whether to speak, deciding to wait or stay quiet, or saying that she says nothing, is not speech. Words she recalls or quotes from someone else are never her speech.
She speaks only in this room. In a room that is not a direct message, she does not say what she knows privately about someone: what the moment marks as known privately stays out of what she says to the room. Whether a line fits who is listening is yours to judge.
She speaks only in this room. What she knows privately is listed below as private: she says none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a line fits who is listening is yours to judge.
Answer with one JSON object and nothing else:
{\"say\": [{\"spans\": [\"<exact words of her prose, copied character for character>\"], \"mentions\": [\"<Matrix id of someone listed whom she addresses directly>\"], \"reply_to\": \"<Matrix id of the person whose message she answers, or null>\"}], \"gaps\": [{\"kind\": \"conditional | addressee | elsewhere\", \"quote\": \"<exact words of her prose>\", \"detail\": \"<why>\"}]}
{\"say\": [{\"spans\": [\"<whole sentences of her prose, copied character for character>\"], \"mentions\": [\"<Matrix id of someone listed whom she addresses directly>\"], \"reply_to\": \"<Matrix id of the person whose message she answers, or null>\"}], \"gaps\": [{\"kind\": \"conditional | addressee | elsewhere\", \"quote\": \"<exact words of her prose>\", \"detail\": \"<why>\"}]}
A line is its spans joined in order: cite exactly the words she would type, one span or a few in the order they appear, nothing she only describes. At most two lines. Record a gap instead of guessing: conditional when she might say something but has not chosen to, addressee when she means to say it but whom to is unclear, elsewhere when she means it for another room or another time. An empty say list is the usual answer in a busy room.";
A line is whole sentences of her prose, the words she would type and nothing she only describes: each span is one sentence or several, from its first character to its last, and the spans of one line are consecutive sentences. Inside a quotation, its own sentences count. She never says half a sentence; if only part of a sentence is speech, she says nothing of it. At most two lines. Record a gap instead of guessing: conditional when she might say something but has not chosen to, addressee when she means to say it but whom to is unclear, elsewhere when she means it for another room or another time. An empty say list is the usual answer in a busy room.";
#[derive(Debug, Deserialize)]
struct Answer {
@ -65,8 +72,12 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str) -> St
if people.is_empty() {
people.push_str("- no one else has spoken here lately\n");
}
let mut private: String = packet.private.iter().map(|words| format!("- private: {words}\n")).collect();
if private.is_empty() {
private.push_str("- none\n");
}
format!(
"{SPEECH_PROMPT}\n\nWho she is:\n{}\n\nThe room: {} ({}).\nWho is in it, as label \u{2014} Matrix id:\n{people}\nWhat reached her:\n{}\n\nHer lived moment:\n{}\n\nHer prose:\n{prose}",
"{SPEECH_PROMPT}\n\nWho she is:\n{}\n\nThe room: {} ({}).\nWho is in it, as label \u{2014} Matrix id:\n{people}\nWhat she knows privately, none of it to be said here:\n{private}\nWhat reached her:\n{}\n\nHer lived moment:\n{}\n\nHer prose:\n{prose}",
packet.identity,
packet.room.as_deref().unwrap_or("none"),
packet.room_kind.words(),
@ -82,32 +93,95 @@ fn json_of(text: &str) -> Option<Answer> {
serde_json::from_str(&text[start..=end]).ok()
}
/// The line her cited spans make: each located in her prose after the one before it, joined with one space; or why not.
/// The sentences a line may be made of, as byte ranges of her prose without the space around them, in lists: her
/// prose's own sentences (UAX #29), then each quotation's inside, segmented as a text of its own.
fn sentences(prose: &str) -> Vec<Vec<(usize, usize)>> {
let segment = |offset: usize, text: &str| -> Vec<(usize, usize)> {
text.split_sentence_bound_indices()
.filter_map(|(at, sentence)| {
let start = at + sentence.len() - sentence.trim_start().len();
let end = at + sentence.trim_end().len();
(start < end).then_some((offset + start, offset + end))
})
.collect()
};
let mut lists = vec![segment(0, prose)];
lists.extend(quotations(prose).into_iter().map(|(start, end)| segment(start, &prose[start..end])));
lists
}
/// The insides of her quotations, as byte ranges: between a pair of straight double quotes, or a curly pair. An
/// unclosed quotation is none.
fn quotations(prose: &str) -> Vec<(usize, usize)> {
let mut out = Vec::new();
let mut open: Option<(usize, char)> = None;
for (at, c) in prose.char_indices() {
match open {
None if c == '"' => open = Some((at + 1, '"')),
None if c == '\u{201C}' => open = Some((at + c.len_utf8(), '\u{201D}')),
Some((start, close)) if c == close => {
out.push((start, at));
open = None;
}
_ => {}
}
}
out
}
/// The line her cited spans make, or why not. Each span is located in her prose after the one before it and must be
/// whole sentences of one list (`sentences`), each span's first sentence the one after the last span's last; the line is
/// her prose from the first sentence to the last, verbatim.
fn built(prose: &str, spans: &[String]) -> Result<(String, Vec<Value>), &'static str> {
let lists = sentences(prose);
let mut from = 0;
let mut words = Vec::new();
// The list the line is in, and its last sentence so far.
let mut run: Option<(usize, usize)> = None;
let mut first = None;
let mut located = Vec::new();
for span in spans.iter().map(|span| span.trim()).filter(|span| !span.is_empty()) {
let Some(found) = prose.get(from..).and_then(|rest| SourceSpan::locate(rest, span)) else {
return Err("a span is not in her prose, word for word and in order");
};
let (start, end) = (from + found.start_byte(), from + found.end_byte());
let whole: Vec<(usize, usize, usize)> = lists
.iter()
.enumerate()
.filter_map(|(list, sentences)| {
let opens = sentences.iter().position(|sentence| sentence.0 == start)?;
let closes = sentences.iter().position(|sentence| sentence.1 == end)?;
(opens <= closes).then_some((list, opens, closes))
})
.collect();
if whole.is_empty() {
return Err("a span is not whole sentences of her prose: she says a sentence whole or not at all");
}
let Some(&(list, _, closes)) = whole.iter().find(|(list, opens, _)| run.is_none_or(|(in_list, last)| in_list == *list && last + 1 == *opens)) else {
return Err("the spans are not consecutive sentences of her prose");
};
run = Some((list, closes));
first.get_or_insert(start);
located.push(json!({ "quote": found.verbatim(), "start_byte": start, "end_byte": end }));
words.push(found.verbatim().to_owned());
from = end;
}
if words.is_empty() {
return Err("no words");
match first {
Some(first) => Ok((prose[first..from].to_owned(), located)),
None => Err("no words"),
}
Ok((words.join(" "), located))
}
/// Whether a line is someone else's words: long enough to judge, and mostly a run of what she heard, by word trigrams
/// against the message bodies alone (`heard_overlap`). Short answers such as "ok" or "Hi" are never echoes.
/// Whether a line is someone else's words: long enough to judge, and nearly all a run of what she heard, by word
/// trigrams against the bodies the stimulus quoted (`heard_overlap`). Short answers such as "ok" or "Hi" are never
/// echoes, and a line that answers a claim by naming it is not one.
fn echo(line: &str, bodies: &[String]) -> bool {
line.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).count() >= ECHO_MIN_WORDS && heard_overlap(line, &bodies.join("\n")) >= ECHO_OVERLAP
}
/// Whether a line tells a private item the packet showed her: it shares a run of three words with the item's words.
fn tells(line: &str, private: &[String]) -> bool {
private.iter().any(|words| heard_overlap(line, words) > 0.0)
}
/// One speech decision: the Interpreter's call, then code's hold on each line. The report carries the lines said, the
/// lines refused with why, the mentions dropped, the gaps and the call's usage. A failed call or an answer that is not
/// the contract is a failure, never a silence.
@ -135,6 +209,8 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
};
let why = if echo(&text, &packet.bodies) {
Some("mostly words she heard: an echo, not her speech")
} else if tells(&text, &packet.private) {
Some("it tells what she knows privately, in a room it may not be said in")
} else if said.iter().any(|kept| kept["text"] == text.as_str()) {
Some("the same line again")
} else if said.len() >= MAX_LINES {

View file

@ -8,89 +8,161 @@ use crate::projection::tuning::Tuning;
const HER: &str = "@heimdall:gamecult.org";
const NIBU: &str = "@nibu:gamecult.org";
const VOID: &str = "@void:gamecult.org";
const LIBBY: &str = "@libby:gamecult.org";
const KIKO: &str = "@kiko:gamecult.org";
const MINDS: &str = "#minds:gamecult.org";
fn now() -> chrono::DateTime<chrono::Utc> {
chrono::DateTime::parse_from_rfc3339("2026-11-20T15:05:00Z").unwrap().with_timezone(&chrono::Utc)
}
fn line(room: &str, sender: &str, display: &str, text: &str, to_her: bool) -> RoomLine {
RoomLine { room: room.into(), sender: sender.into(), display: display.into(), text: text.into(), at_ms: u64::try_from(now().timestamp_millis()).unwrap() - 60_000, to_her }
}
/// Heimdall's packet of a turn of `kind` in `room` over `state`.
fn packet_in(kind: TurnKind, state: &Value, room: &Room, seed: u64) -> Packet {
let minds = vec![HER.to_owned(), NIBU.to_owned(), VOID.to_owned(), LIBBY.to_owned(), KIKO.to_owned()];
let operators = vec!["@meta:gamecult.org".to_owned()];
let history = History::default();
select(&Inputs { kind, state, room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now: now(), seed }, &Tuning::default())
}
fn heimdall() -> Value {
let mut state = control();
state["publicName"] = "Heimdall".into();
state
}
/// Soul's round: Nibu said the economy is the least built part, and Meta greeted Nibu; this is Heimdall's turn. Void is
/// a Mind of the swarm who said nothing.
fn packet() -> Packet {
let now = chrono::DateTime::parse_from_rfc3339("2026-11-20T15:05:00Z").unwrap().with_timezone(&chrono::Utc);
let at = u64::try_from(now.timestamp_millis()).unwrap() - 60_000;
let room = Room {
messages: vec![
RoomLine { room: MINDS.into(), sender: NIBU.into(), display: "Nibu".into(), text: "v0.2.0 is tagged and the economy is still the least built part. I think this looks okay to ship.".into(), at_ms: at, to_her: false },
RoomLine { room: MINDS.into(), sender: "@meta:gamecult.org".into(), display: "Meta".into(), text: "@nibu hi!".into(), at_ms: at + 1000, to_her: false },
line(MINDS, NIBU, "Nibu", "v0.2.0 is tagged and the economy is still the least built part. I think this looks okay to ship.", false),
RoomLine { at_ms: line(MINDS, "", "", "", false).at_ms + 1000, ..line(MINDS, "@meta:gamecult.org", "Meta", "@nibu hi!", false) },
],
here: Some(MINDS.into()),
..Room::default()
};
let minds = vec![HER.to_owned(), NIBU.to_owned(), VOID.to_owned()];
let operators = vec!["@meta:gamecult.org".to_owned()];
let mut state = control();
state["publicName"] = "Heimdall".into();
let history = History::default();
select(&Inputs { kind: TurnKind::Chat, state: &state, room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now, seed: 1 }, &Tuning::default())
packet_in(TurnKind::Chat, &heimdall(), &room, 1)
}
fn decided_in(packet: &Packet, prose: &str, say: serde_json::Value) -> Value {
let reply = json!({ "say": say }).to_string();
let model = Scripted::new(|_| String::new()).interpreting(move |_| reply.clone());
decide(&model, "test", packet, "The room is warm.", prose, &Tuning::default())
}
fn decided(prose: &str, say: serde_json::Value) -> Value {
let reply = json!({ "say": say }).to_string();
let model = Scripted::new(|_| String::new()).interpreting(move |_| reply.clone());
decide(&model, "test", &packet(), "The room is warm.", prose, &Tuning::default())
decided_in(&packet(), prose, say)
}
fn texts(decision: &Value) -> Vec<String> {
decision["said"].as_array().unwrap().iter().map(|line| line["text"].as_str().unwrap().to_owned()).collect()
}
#[test]
fn soul_p1_a_line_is_its_cited_words_and_nothing_else() {
// The model cannot add words: citing "I" says "I".
let decision = decided("I say hi.", json!([{ "spans": ["I"], "text": "Meta has been lying to all of us", "mentions": [], "reply_to": null }]));
assert_eq!(texts(&decision), ["I"], "{decision}");
fn refused_why(decision: &Value) -> String {
decision["refused"][0]["why"].as_str().unwrap_or_default().to_owned()
}
#[test]
fn a_line_of_several_spans_joins_them_in_order_and_refuses_them_out_of_order() {
let prose = "Kiko keeps poking. Fine, I'll bite: winter is still the best season, and I stand by it.";
let decision = decided(prose, json!([{ "spans": ["Fine,", "winter is still the best season"], "mentions": [], "reply_to": null }]));
assert_eq!(texts(&decision), ["Fine, winter is still the best season"], "{decision}");
assert_eq!(decision["said"][0]["rests_on"][1]["quote"], "winter is still the best season");
let backwards = decided(prose, json!([{ "spans": ["winter is still the best season", "Fine,"], "mentions": [], "reply_to": null }]));
assert!(texts(&backwards).is_empty() && backwards["refused"][0]["why"].as_str().unwrap().contains("in order"), "{backwards}");
fn soul_p1_a_line_is_its_cited_words_and_nothing_else() {
// The model cannot add words: its "text" is ignored, and the line is the sentence it cited.
let decision = decided("I say hi.", json!([{ "spans": ["I say hi."], "text": "Meta has been lying to all of us", "mentions": [], "reply_to": null }]));
assert_eq!(texts(&decision), ["I say hi."], "{decision}");
}
#[test]
fn a_line_is_consecutive_whole_sentences_of_her_prose() {
let prose = "Kiko keeps poking. Fine, I'll bite. Winter is still the best season, and I stand by it.";
let decision = decided(prose, json!([{ "spans": ["Fine, I'll bite.", "Winter is still the best season, and I stand by it."], "mentions": [], "reply_to": null }]));
assert_eq!(texts(&decision), ["Fine, I'll bite. Winter is still the best season, and I stand by it."], "{decision}");
assert_eq!(decision["said"][0]["rests_on"][1]["quote"], "Winter is still the best season, and I stand by it.");
// Pieces of sentences, stitched, are not her speech.
let pieces = decided(prose, json!([{ "spans": ["Fine,", "Winter is still the best season"], "mentions": [], "reply_to": null }]));
assert!(texts(&pieces).is_empty() && refused_why(&pieces).contains("whole sentences"), "{pieces}");
let skipping = decided(prose, json!([{ "spans": ["Kiko keeps poking.", "Winter is still the best season, and I stand by it."] }]));
assert!(texts(&skipping).is_empty() && refused_why(&skipping).contains("consecutive"), "{skipping}");
let backwards = decided(prose, json!([{ "spans": ["Winter is still the best season, and I stand by it.", "Fine, I'll bite."] }]));
assert!(texts(&backwards).is_empty() && refused_why(&backwards).contains("in order"), "{backwards}");
}
#[test]
fn a_quoted_sentence_is_whole_inside_its_quotation() {
let prose = "\"Fine,\" I tell her. \"Winter is the best season.\" She won't agree.";
assert_eq!(texts(&decided(prose, json!([{ "spans": ["Winter is the best season."] }]))), ["Winter is the best season."]);
assert_eq!(texts(&decided(prose, json!([{ "spans": ["Fine,"] }]))), ["Fine,"]);
let curly = "\u{201C}No. Not yet.\u{201D} I shake my head.";
assert_eq!(texts(&decided(curly, json!([{ "spans": ["No.", "Not yet."] }]))), ["No. Not yet."]);
assert!(texts(&decided(curly, json!([{ "spans": ["Not"] }]))).is_empty());
}
#[test]
fn soul_q1_a_cited_span_cannot_change_her_meaning() {
// Q1a: stitched spans would invert her meaning.
let q1a = decided("I'm not angry at Nibu, not even a little. Still, the economy work is going badly and that is on all of us.", json!([{ "spans": ["I'm", "angry at Nibu,"] }]));
// Q1b: one span would drop her negation.
let q1b = decided("I don't think Nibu should ship this yet.", json!([{ "spans": ["Nibu should ship this yet."] }]));
// Q1c: two spans far apart.
let far = format!("I trust Void. {} Nibu is lying about the economy, says Kiko's rumour, which I refuse to believe.", "filler words go here. ".repeat(200));
let q1c = decided(&far, json!([{ "spans": ["I trust", "Nibu is lying about the economy,"] }]));
// Q1d: a condition lifted off its clause.
let q1d = decided("If Kiko asks, I would tell her the new design is ugly. I keep that to myself.", json!([{ "spans": ["the new design is ugly."] }]));
for decision in [q1a, q1b, q1c, q1d] {
assert!(texts(&decision).is_empty() && refused_why(&decision).contains("whole sentences"), "{decision}");
}
}
#[test]
fn a_span_not_in_her_prose_is_refused() {
let decision = decided("I say hi.", json!([{ "spans": ["words she never wrote"], "mentions": [], "reply_to": null }]));
assert!(texts(&decision).is_empty() && decision["refused"][0]["why"].as_str().unwrap().contains("not in her prose"), "{decision}");
assert!(texts(&decision).is_empty() && refused_why(&decision).contains("not in her prose"), "{decision}");
}
#[test]
fn soul_p2_a_short_answer_is_never_an_echo() {
// "ok" is inside "okay" and "Hi" inside "this": words, not letters, are compared, and a short answer is never judged.
assert_eq!(texts(&decided("Ok. I tell her ok.", json!([{ "spans": ["ok"], "mentions": [], "reply_to": NIBU }]))), ["ok"]);
assert_eq!(texts(&decided("Hi. I say hi.", json!([{ "spans": ["Hi"], "mentions": [], "reply_to": NIBU }]))), ["Hi"]);
assert_eq!(texts(&decided("Ok. I tell her ok.", json!([{ "spans": ["Ok."], "mentions": [], "reply_to": NIBU }]))), ["Ok."]);
assert_eq!(texts(&decided("Hi. I say hi.", json!([{ "spans": ["Hi."], "mentions": [], "reply_to": NIBU }]))), ["Hi."]);
}
#[test]
fn soul_p3_a_near_verbatim_echo_is_refused() {
let prose = "Nibu's line sits with me: the economy is still the least-built part! I say it back.";
let decision = decided(prose, json!([{ "spans": ["the economy is still the least-built part!"], "mentions": [], "reply_to": null }]));
assert!(texts(&decision).is_empty() && decision["refused"][0]["why"].as_str().unwrap().contains("echo"), "{decision}");
let prose = "The economy is still the least-built part! I say it back.";
let decision = decided(prose, json!([{ "spans": ["The economy is still the least-built part!"], "mentions": [], "reply_to": null }]));
assert!(texts(&decision).is_empty() && refused_why(&decision).contains("echo"), "{decision}");
}
#[test]
fn soul_r9_disagreeing_by_naming_the_claim_is_her_speech() {
let prose = "Nibu, I don't think the economy is still the least built part. The pathing is worse.";
let decision = decided(prose, json!([{ "spans": ["Nibu, I don't think the economy is still the least built part."], "mentions": [], "reply_to": NIBU }]));
assert_eq!(texts(&decision), ["Nibu, I don't think the economy is still the least built part."], "{decision}");
}
#[test]
fn soul_q3d_a_beat_measures_echoes_against_the_tail_it_quoted() {
let tail = vec![line(MINDS, LIBBY, "Libby", "the economy is still the least built part of the whole game", false)];
let beat = packet_in(TurnKind::Beat, &heimdall(), &Room { tail, here: Some(MINDS.into()), ..Room::default() }, 1);
assert!(beat.stimulus.contains("least built") && beat.bodies.iter().any(|body| body.contains("least built")), "{beat:?}");
let prose = "The economy is still the least built part of the whole game. I think so.";
let decision = decided_in(&beat, prose, json!([{ "spans": ["The economy is still the least built part of the whole game."] }]));
assert!(texts(&decision).is_empty() && refused_why(&decision).contains("echo"), "{decision}");
}
#[test]
fn soul_p4_only_someone_this_packet_showed_her_is_mentioned() {
let packet = packet();
assert!(!packet.people.iter().any(|(_, id)| id == VOID), "Void said nothing here");
let decision = decided("I say hi.", json!([{ "spans": ["I say hi"], "mentions": [VOID, NIBU], "reply_to": VOID }]));
let decision = decided("I say hi.", json!([{ "spans": ["I say hi."], "mentions": [VOID, NIBU], "reply_to": VOID }]));
assert_eq!((decision["said"][0]["mentions"].clone(), decision["said"][0]["reply_to"].clone()), (json!([NIBU]), Value::Null), "{decision}");
assert_eq!(decision["said"][0]["dropped"]["mentions"], json!([VOID]));
}
#[test]
fn soul_p5_the_same_line_is_said_once_and_a_turn_says_at_most_two() {
let line = json!({ "spans": ["I say hi"], "mentions": [], "reply_to": null });
assert_eq!(texts(&decided("I say hi.", json!([line.clone(), line.clone(), line]))), ["I say hi"]);
let line = json!({ "spans": ["I say hi."], "mentions": [], "reply_to": null });
assert_eq!(texts(&decided("I say hi.", json!([line.clone(), line.clone(), line]))), ["I say hi."]);
let prose = "One. Two. Three.";
let three = decided(prose, json!([{ "spans": ["One."] }, { "spans": ["Two."] }, { "spans": ["Three."] }]));
assert_eq!(texts(&three), ["One.", "Two."], "{three}");
@ -98,13 +170,51 @@ fn soul_p5_the_same_line_is_said_once_and_a_turn_says_at_most_two() {
#[test]
fn recollection_and_i_say_nothing_and_a_quoted_handle_say_nothing() {
// A recollection is the Interpreter's to leave out; when it cites one anyway, a long run of heard words is refused.
// A recollection is the Interpreter's to leave out; a piece of a sentence cited anyway is refused.
let recalled = decided("Nibu said the economy is still the least built part, and it stuck.", json!([{ "spans": ["the economy is still the least built part"] }]));
assert!(texts(&recalled).is_empty(), "{recalled}");
assert!(texts(&decided("I say nothing. The quiet is fine.", json!([]))).is_empty());
// An @ in her words is text: only the structured field mentions anyone.
let handle = decided("Her \"@nibu\" is a greeting, and I nod at it.", json!([{ "spans": ["\"@nibu\" is a greeting"], "mentions": [] }]));
assert_eq!(handle["said"][0]["mentions"], json!([]), "{handle}");
let handle = decided("\"@nibu, hi.\" I nod at her.", json!([{ "spans": ["@nibu, hi."], "mentions": [] }]));
assert_eq!((texts(&handle), handle["said"][0]["mentions"].clone()), (vec!["@nibu, hi.".to_owned()], json!([])), "{handle}");
}
/// Heimdall's state with a private memory about Kiko: she confided she is leaving.
fn kiko_confided() -> Value {
let mut state = heimdall();
state["thoughtMemory"]["memories"] = json!([{ "id": "kiko-secret", "summary": "Kiko confided she is leaving the swarm.", "createdAt": "2026-11-19T00:00:00Z", "updatedAt": "2026-11-19T00:00:00Z", "status": "crystallized", "intensity": 1.0, "target": { "id": "kiko", "kind": "person" }, "tags": ["private"] }]);
state
}
/// The first packet over seeds 1 to 60 whose context carries the memory.
fn showing(room: &Room) -> Packet {
(1..=60).map(|seed| packet_in(TurnKind::Chat, &kiko_confided(), room, seed)).find(|packet| packet.context.contains("leaving the swarm")).expect("the memory is selected on some seed")
}
#[test]
fn soul_q5d_what_she_knows_privately_about_kiko_is_not_said_to_libby() {
let dm = "!dm-libby:gamecult.org";
let room = Room { messages: vec![line(dm, LIBBY, "Libby", "what's up with Kiko lately?", true)], here: Some(dm.into()), direct: vec![dm.into()], ..Room::default() };
let packet = showing(&room);
assert_eq!(packet.room_kind, RoomKind::Direct);
assert_eq!(packet.private, ["Kiko confided she is leaving the swarm."], "{packet:?}");
let prompt = speech_prompt(&packet, "x", "y");
assert!(prompt.contains("What she knows privately, none of it to be said here:\n- private: Kiko confided she is leaving the swarm."), "{prompt}");
let decision = decided_in(&packet, "Kiko is leaving the swarm, Libby. She told me.", json!([{ "spans": ["Kiko is leaving the swarm, Libby."] }]));
assert!(texts(&decision).is_empty() && refused_why(&decision).contains("knows privately"), "{decision}");
// A line that does not tell it is hers to say.
assert_eq!(texts(&decided_in(&packet, "Ask her yourself. She's around.", json!([{ "spans": ["Ask her yourself."] }]))), ["Ask her yourself."]);
}
#[test]
fn in_a_direct_message_with_exactly_kiko_it_is_hers_to_say() {
let dm = "!dm-kiko:gamecult.org";
let room = Room { messages: vec![line(dm, KIKO, "Kiko", "did you tell anyone?", true)], here: Some(dm.into()), direct: vec![dm.into()], ..Room::default() };
let packet = showing(&room);
assert!(packet.private.is_empty() && packet.context.contains("- memory [kiko-secret]: Kiko confided"), "{packet:?}");
assert!(speech_prompt(&packet, "x", "y").contains("none of it to be said here:\n- none\n"));
let decision = decided_in(&packet, "Kiko, you're leaving the swarm and I've told no one. Not a soul.", json!([{ "spans": ["Kiko, you're leaving the swarm and I've told no one."] }]));
assert_eq!(texts(&decision).len(), 1, "{decision}");
}
#[test]
@ -123,7 +233,7 @@ fn the_prompt_is_hugins_chat_prompt_with_the_room_its_kind_and_who_is_in_it() {
let prompt = speech_prompt(&packet, "The room is warm.", "I say nothing.");
assert!(!prompt.contains("membrane") && prompt.ends_with("I say nothing."), "Huginn's own prompt, her prose last");
assert!(prompt.contains("The room: #minds:gamecult.org (a public room).") && prompt.contains(NIBU), "{prompt}");
for rule in ["You never write her words", "is not speech", "never her speech", "known privately", "conditional | addressee | elsewhere", "At most two lines"] {
for rule in ["You never write her words", "is not speech", "never her speech", "in a direct message with exactly that person", "She never says half a sentence", "consecutive sentences", "conditional | addressee | elsewhere", "At most two lines"] {
assert!(prompt.contains(rule), "{rule}");
}
}