persona tests: the test-only re-exports are test-only; the run's end state rides the cast; the packet names the operator in the room line

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-01 16:18:41 +01:00
commit d4ea78ce4d
3 changed files with 17 additions and 9 deletions

View file

@ -51,9 +51,15 @@ pub use domain::{DomainFacts, DomainSource, HttpForge, MindDomain};
pub use narrate::{Answer, Failed, KitModel, Model, Spent, StepRequest, Stepped, ToolCall, connector_key}; pub use narrate::{Answer, Failed, KitModel, Model, Spent, StepRequest, Stepped, ToolCall, connector_key};
pub use read::{LiveReads, ReadFailure, ReadFixture, ReadRequest, ReadSource}; pub use read::{LiveReads, ReadFailure, ReadFixture, ReadRequest, ReadSource};
pub use select::TurnKind; pub use select::TurnKind;
pub(crate) use commit::{Applied, Heard, apply as apply_commit}; pub(crate) use commit::Applied;
pub(crate) use interpret::{heard_of, interpret_and_put, put_applied}; #[cfg(test)]
pub(crate) use turn::{DAY_CAP_HOLD, Taken, decided, failed, failed_run, history, is_wake}; pub(crate) use commit::Heard;
pub(crate) use interpret::{heard_of, interpret_and_put};
#[cfg(test)]
pub(crate) use interpret::put_applied;
pub(crate) use turn::{DAY_CAP_HOLD, decided, failed, failed_run, history, is_wake};
#[cfg(test)]
pub(crate) use turn::Taken;
pub(crate) use agent::say::{Mouth, settle_handed}; pub(crate) use agent::say::{Mouth, settle_handed};
pub(crate) use wake::{Fault, Waked, wake}; pub(crate) use wake::{Fault, Waked, wake};
pub use tuning::{TUNING_FILE, TUNING_ROOT}; pub use tuning::{TUNING_FILE, TUNING_ROOT};

View file

@ -139,6 +139,7 @@ impl ReadSource for CastReads<'_> {
} }
} }
#[derive(Clone)]
struct Member { struct Member {
entry: CastEntry, entry: CastEntry,
state: Value, state: Value,
@ -547,8 +548,9 @@ fn run(harness: &Harness, plan: &SimFile, members: &[Member], repeat: usize) ->
turns.push(turn); turns.push(turn);
} }
} }
let states: Vec<Value> = held.iter().map(|held| held.0.borrow().clone()).collect(); // The cast as the run ended: each Mind with the state its Interpreter left her.
let metrics = metrics(members, &states, &lines, &rounds_of, &causes, opening, &turns, plan.rounds); let ended: Vec<Member> = members.iter().zip(&held).map(|(member, held)| Member { state: held.0.borrow().clone(), ..member.clone() }).collect();
let metrics = metrics(&ended, &lines, &rounds_of, &causes, opening, &turns, plan.rounds);
let transcript: Vec<Value> = lines.iter().zip(&rounds_of).zip(&causes).map(|((line, round), cause)| json!({ "round": round, "room": line.room, "from": line.from, "name": line.name, "says": line.says, "mind": cast.contains(&line.from), "woke": cause })).collect(); let transcript: Vec<Value> = lines.iter().zip(&rounds_of).zip(&causes).map(|((line, round), cause)| json!({ "round": round, "room": line.room, "from": line.from, "name": line.name, "says": line.says, "mind": cast.contains(&line.from), "woke": cause })).collect();
Ok(json!({ "repeat": repeat + 1, "seed": seed, "transcript": transcript, "turns": turns, "metrics": metrics })) Ok(json!({ "repeat": repeat + 1, "seed": seed, "transcript": transcript, "turns": turns, "metrics": metrics }))
} }
@ -606,11 +608,11 @@ fn reply_chains(lines: &[Line], causes: &[Option<&str>], opening: usize, cast: &
json!(out) json!(out)
} }
fn metrics(members: &[Member], states: &[Value], lines: &[Line], rounds_of: &[usize], causes: &[Option<&str>], opening: usize, turns: &[Value], rounds: usize) -> Value { fn metrics(members: &[Member], lines: &[Line], rounds_of: &[usize], causes: &[Option<&str>], opening: usize, turns: &[Value], rounds: usize) -> Value {
let cast: Vec<&str> = members.iter().map(|member| member.entry.id.as_str()).collect(); let cast: Vec<&str> = members.iter().map(|member| member.entry.id.as_str()).collect();
let outcome = |turn: &&Value, what: &str| turn["outcome"] == what; let outcome = |turn: &&Value, what: &str| turn["outcome"] == what;
let mut per = BTreeMap::new(); let mut per = BTreeMap::new();
for (index, member) in members.iter().enumerate() { for member in members {
let mine: Vec<&Value> = turns.iter().filter(|turn| turn["id"] == member.entry.id.as_str()).collect(); let mine: Vec<&Value> = turns.iter().filter(|turn| turn["id"] == member.entry.id.as_str()).collect();
let (spoke, silent, failed) = (mine.iter().filter(|turn| outcome(turn, "spoke")).count(), mine.iter().filter(|turn| outcome(turn, "silent")).count(), mine.iter().filter(|turn| outcome(turn, "failed")).count()); let (spoke, silent, failed) = (mine.iter().filter(|turn| outcome(turn, "spoke")).count(), mine.iter().filter(|turn| outcome(turn, "silent")).count(), mine.iter().filter(|turn| outcome(turn, "failed")).count());
let mut addressed = BTreeMap::new(); let mut addressed = BTreeMap::new();
@ -640,7 +642,7 @@ fn metrics(members: &[Member], states: &[Value], lines: &[Line], rounds_of: &[us
"intentions_ready": intentions("ready"), "intentions_ready": intentions("ready"),
"identity_changes": interpreted.iter().map(|did| did["identity"].as_array().map_or(0, Vec::len)).sum::<usize>(), "identity_changes": interpreted.iter().map(|did| did["identity"].as_array().map_or(0, Vec::len)).sum::<usize>(),
"refused": interpreted.iter().map(|did| did["refused"].as_array().map_or(0, Vec::len)).sum::<usize>(), "refused": interpreted.iter().map(|did| did["refused"].as_array().map_or(0, Vec::len)).sum::<usize>(),
"short_term_at_end": states[index]["thoughtMemory"]["shortTerm"].as_array().map_or(0, Vec::len), "short_term_at_end": member.state["thoughtMemory"]["shortTerm"].as_array().map_or(0, Vec::len),
}); });
per.insert(member.entry.name.clone(), json!({ "turns": mine.len(), "messages": spoke, "failed": failed, "silence_rate": if answered == 0 { Value::Null } else { json!(silent as f64 / answered as f64) }, "addressed": addressed, "interpreter": interpreter })); per.insert(member.entry.name.clone(), json!({ "turns": mine.len(), "messages": spoke, "failed": failed, "silence_rate": if answered == 0 { Value::Null } else { json!(silent as f64 / answered as f64) }, "addressed": addressed, "interpreter": interpreter }));
} }

View file

@ -2486,7 +2486,7 @@ fn a_line_in_her_own_room_is_said_to_her_only_when_it_is_not_for_another_mind()
assert!(to_her, "the control: a human's line in her own room that names no one is to her"); assert!(to_her, "the control: a human's line in her own room that names no one is to her");
let (to_her, heard, arrival) = said_to_her(meta("Give Libby a yes or no by tonight")); let (to_her, heard, arrival) = said_to_her(meta("Give Libby a yes or no by tonight"));
assert!(!to_her, "a line naming another Mind is not said to her"); assert!(!to_her, "a line naming another Mind is not said to her");
assert!(heard.starts_with("Meta, in #swarm:gamecult.org: \"Give Libby a yes or no"), "it is heard in the room: {heard}"); assert!(heard.starts_with("Meta, the operator, in #swarm:gamecult.org: \"Give Libby a yes or no"), "it is heard in the room: {heard}");
assert!(!arrival.contains("Meta"), "and no one turned to her: {arrival}"); assert!(!arrival.contains("Meta"), "and no one turned to her: {arrival}");
let (to_her, _, _) = said_to_her(ChatDelivery { mentions: vec!["@kiko:gamecult.org".into()], ..meta("a playable file, please") }); let (to_her, _, _) = said_to_her(ChatDelivery { mentions: vec!["@kiko:gamecult.org".into()], ..meta("a playable file, please") });
assert!(!to_her, "a tag of another Mind"); assert!(!to_her, "a tag of another Mind");