Speech binds to her words: a spoken line is her prose verbatim; Huginn's chat Interpreter prompt; she speaks only in the turn's room
Soul's hold on #81 and Self's privacy decision. - F1: a spoken line is exactly the spans of her prose the Interpreter cites, located in order by Ghostlight's SourceSpan::locate and joined with one space. The model never writes the words; `text` is gone from the contract. The Persona writes the words she would type, never a description of them. Given up: indirect speech and any paraphrase by the Interpreter. - F3: Huginn owns a short chat Interpreter prompt (what, where, to whom; gaps conditional, addressee, elsewhere); Ghostlight's membrane and the INTERPRETER_GUIDANCE patch are gone. `[interpreter]` keeps only the model. - F2: an echo is a line of four words or more whose word trigrams are mostly the heard message bodies (heard_overlap); short answers are never echoes. - F4: mentions and reply targets only for people this packet showed her. - F5: a line said once; at most two lines a turn. - F6: stale docs on the Mind run, the exchange and the policies. - F7: a human's line ends a Mind's run only in a room the run has lines in. - Privacy: she speaks only in the turn's room; the Interpreter is told the room, its kind (public, her own, a direct message) and who is in it, and not to say in a room what she knows privately; the packet frames bond summaries and memories about a person as known privately everywhere but a direct message with that person. - The simulation's turn is in the room of the line that woke her. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
14be61a167
commit
02e78e1427
14 changed files with 346 additions and 210 deletions
|
|
@ -199,6 +199,7 @@ fn run_project(args: &[String]) -> Result<String> {
|
|||
through,
|
||||
last_heard: vec![],
|
||||
recent: vec![],
|
||||
own_rooms: vec![],
|
||||
};
|
||||
let report = project(&organs, &request, chrono::Utc::now())?;
|
||||
let addressing = &report["addressing"];
|
||||
|
|
|
|||
|
|
@ -437,8 +437,8 @@ pub(crate) enum WakePolicy {
|
|||
/// only while fewer than this many Mind lines in a row came before it across her rooms (`LineFacts::mind_run`): the
|
||||
/// backstop.
|
||||
HumansPace(usize),
|
||||
/// `Ruled`, with at most this many Mind lines in a row in a room before a human must speak again: a Mind's line past
|
||||
/// the cap wakes no one.
|
||||
/// `Ruled`, with at most this many lines in her current Mind-only run (`LineFacts::mind_run`) before a human must
|
||||
/// speak where it runs: a Mind's line past the cap wakes no one.
|
||||
NamesWithCap(usize),
|
||||
/// The swarm's old loop, a control: any line in her rooms but her own.
|
||||
AllMessages,
|
||||
|
|
@ -459,8 +459,8 @@ pub(crate) enum WakeCause {
|
|||
/// and passes the default; `Live` reads none.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct LineFacts {
|
||||
/// How many Mind lines in a row came before this one, across every room she sees, since a human last spoke in any of
|
||||
/// them: the backstop counts a Mind-only run per Mind, not per room, so a loop cannot dodge it by changing rooms.
|
||||
/// How many lines her current Mind-only run held before this one: one run across every room she sees, so a loop
|
||||
/// cannot dodge the backstop by changing rooms, and ended only by a human's line in a room the run has lines in.
|
||||
pub mind_run: usize,
|
||||
/// The line is in a room of hers: a direct message (the delivery says so) or a room configured as hers.
|
||||
pub own_room: bool,
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ pub struct Request {
|
|||
/// The ids each earlier projection selected, oldest first, for freshness: a simulation's earlier turns of hers.
|
||||
/// Empty live until trace v2 (C3c) carries them.
|
||||
pub recent: Vec<Vec<String>>,
|
||||
/// The rooms that are hers, by the key the lines carry: a simulation's plan. The live body records none yet.
|
||||
pub own_rooms: Vec<String>,
|
||||
}
|
||||
|
||||
/// Her addressee: the heartbeat's row for her when its table holds one, else her own names (handle and public name).
|
||||
|
|
@ -181,7 +183,7 @@ fn own_addressee(addressing: Option<&dyn HeartbeatView>, own_sender: &str, publi
|
|||
fn read_room(chat: &dyn MouthReader, request: &Request, own: &Addressee) -> (Room, Value) {
|
||||
let pending = match chat.pending() {
|
||||
Ok(pending) => pending,
|
||||
Err(fault) => return (Room { here: request.room.clone(), last_heard: request.last_heard.clone(), ..Room::default() }, json!({ "read": false, "why": format!("{fault:#}") })),
|
||||
Err(fault) => return (Room { here: request.room.clone(), last_heard: request.last_heard.clone(), own: request.own_rooms.clone(), ..Room::default() }, json!({ "read": false, "why": format!("{fault:#}") })),
|
||||
};
|
||||
// One key names a room everywhere: the one the tail carries, the alias for a public room and the id for a direct
|
||||
// message (the mouth's alias of a direct room is its id). No table in her body maps a public room's id to its
|
||||
|
|
@ -217,7 +219,8 @@ fn read_room(chat: &dyn MouthReader, request: &Request, own: &Addressee) -> (Roo
|
|||
{
|
||||
report["why"] = json!("no line carries this room id: a public room is named by its alias (#name:server), a direct message by its id");
|
||||
}
|
||||
(Room { messages, tail, here, last_heard: request.last_heard.clone() }, report)
|
||||
let direct = pending.deliveries.iter().filter(|delivery| delivery.is_direct).map(|delivery| delivery.room_alias.clone()).collect();
|
||||
(Room { messages, tail, here, last_heard: request.last_heard.clone(), direct, own: request.own_rooms.clone() }, report)
|
||||
}
|
||||
|
||||
fn packet_json(packet: &Packet) -> Value {
|
||||
|
|
@ -316,7 +319,7 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime<Utc>) -> Result
|
|||
let (own, addressing) = own_addressee(organs.addressing, &request.own_sender, &public_name, now);
|
||||
let (room, room_report) = match organs.chat {
|
||||
Some(chat) => read_room(chat, request, &own),
|
||||
None => (Room { here: request.room.clone(), last_heard: request.last_heard.clone(), ..Room::default() }, json!({ "read": false, "why": "no mouth is configured" })),
|
||||
None => (Room { here: request.room.clone(), last_heard: request.last_heard.clone(), own: request.own_rooms.clone(), ..Room::default() }, json!({ "read": false, "why": "no mouth is configured" })),
|
||||
};
|
||||
// Freshness and her own recent words come from trace v2, which the commit writes (C3c); until then only what the
|
||||
// caller carried from earlier turns of its own.
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ Eureka (she/her). Dry, direct, almost feral; zeal aimed at revealing.
|
|||
--- context
|
||||
- now: Thursday 19 November, 14:05 UTC
|
||||
- mood: lighter, more settled than middling
|
||||
- bond [bond-kiko] Kiko — sparring partner: fair trust, heavy friction. Kiko pokes her to stop massaging the pipeline.
|
||||
- bond [bond-libby] Libby — collaborator: fair trust, a little friction. Libby holds the sounds and teases her about the pipeline.
|
||||
- bond [bond-kiko] Kiko — sparring partner: fair trust, heavy friction. She knows privately: Kiko pokes her to stop massaging the pipeline.
|
||||
- bond [bond-libby] Libby — collaborator: fair trust, a little friction. She knows privately: Libby holds the sounds and teases her about the pipeline.
|
||||
- the conversation: Lately Libby with her; Kiko to the room. The last 2 lines are the Minds' alone.
|
||||
- pronouns: Libby — she/her; Kiko — she/her
|
||||
- memory [libby-sounds]: Libby laughed at the door fix.
|
||||
- memory [libby-sounds]: she knows privately: Libby laughed at the door fix.
|
||||
- memory [t1-m0]: The heartbeat stalled at noon.
|
||||
- memory [curse]: Her curse is the knife. The same drive makes her good and will lead her wrong.
|
||||
- need [need-relatedness]: company, strong
|
||||
|
|
|
|||
|
|
@ -333,6 +333,7 @@ pub fn fixture_request(harness: &Harness, fixture: &Fixture, state: Option<Value
|
|||
through,
|
||||
last_heard: fixture.last_heard.clone(),
|
||||
recent: vec![],
|
||||
own_rooms: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -522,12 +523,14 @@ pub(crate) fn interpreter_markdown(out: &mut String, decision: &Value) {
|
|||
let mentions = line["mentions"].as_array().map(|ids| ids.iter().filter_map(Value::as_str).collect::<Vec<_>>().join(", ")).unwrap_or_default();
|
||||
let reply = line["reply_to"].as_str().map_or_else(String::new, |id| format!("; reply to {id}"));
|
||||
let _ = writeln!(out, "- in {}{}{}: {}", line["room"].as_str().unwrap_or_default(), if mentions.is_empty() { String::new() } else { format!(", mentioning {mentions}") }, reply, line["text"].as_str().unwrap_or_default());
|
||||
let _ = writeln!(out, " - rests on: \"{}\"", line["rests_on"]["quote"].as_str().unwrap_or_default());
|
||||
let spans: Vec<String> = line["rests_on"].as_array().into_iter().flatten().map(|span| format!("\"{}\"", span["quote"].as_str().unwrap_or_default())).collect();
|
||||
let _ = writeln!(out, " - her words: {}", spans.join(" + "));
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
for line in decision["refused"].as_array().into_iter().flatten() {
|
||||
let _ = writeln!(out, "- refused ({}): {}", line["why"].as_str().unwrap_or_default(), line["text"].as_str().unwrap_or_default());
|
||||
let what = line["text"].as_str().map_or_else(|| line["spans"].to_string(), str::to_owned);
|
||||
let _ = writeln!(out, "- refused ({}): {what}", line["why"].as_str().unwrap_or_default());
|
||||
}
|
||||
for gap in decision["gaps"].as_array().into_iter().flatten() {
|
||||
let _ = writeln!(out, "- gap: {gap}");
|
||||
|
|
|
|||
|
|
@ -41,20 +41,19 @@ impl Scripted {
|
|||
}
|
||||
}
|
||||
|
||||
/// The recorded Interpreter of the tests: each double-quoted span of her prose is a line said in the first room listed,
|
||||
/// resting on itself, mentioning no one. A test double that keeps the tests' prose readable, not the speech rule: the
|
||||
/// live Interpreter is a model told quotes are not speech.
|
||||
/// 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.
|
||||
pub(crate) fn quoted_lines(prompt: &str) -> String {
|
||||
let prose = prompt.split("Persona turn (already preserved verbatim as source evidence):\n").nth(1).unwrap_or_default();
|
||||
let room = prompt.split("Rooms she may speak in: ").nth(1).and_then(|rooms| rooms.lines().next()).and_then(|rooms| rooms.split("; ").next()).unwrap_or_default();
|
||||
let say: Vec<Value> = prose.split('"').enumerate().filter(|(at, part)| at % 2 == 1 && !part.trim().is_empty()).map(|(_, part)| json!({ "room": room, "text": part, "source_quote": part, "mentions": [], "reply_to": null })).collect();
|
||||
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();
|
||||
json!({ "say": say }).to_string()
|
||||
}
|
||||
|
||||
impl Model for Scripted {
|
||||
fn ask(&self, _request_id: &str, model: &str, prompt: &str) -> std::result::Result<Answer, Failed> {
|
||||
self.calls.borrow_mut().push((model.to_owned(), prompt.to_owned()));
|
||||
let text = if prompt.contains(":interpreter -->") {
|
||||
let text = if prompt.starts_with("You decide what one person says aloud") {
|
||||
(self.interpreter)(prompt)
|
||||
} else if prompt.starts_with("<!-- membrane:") {
|
||||
"The room is slow and so is he.".to_owned()
|
||||
|
|
@ -214,7 +213,7 @@ fn a_batch_runs_every_state_by_scenario_by_sample_into_one_report() {
|
|||
assert!(report.contains(heading), "{heading}\n{report}");
|
||||
}
|
||||
assert!(report.contains("| control | teased | 2/2 |") && report.contains("| control | quiet | 0/2 |"), "{report}");
|
||||
assert!(report.contains("- in #minds:gamecult.org: Winter, still.") && report.contains(" - rests on: \"Winter, still.\"") && report.contains("**Interpreter: nothing said.**"), "{report}");
|
||||
assert!(report.contains("- in #minds:gamecult.org: Winter, still.") && report.contains(" - her words: \"Winter, still.\"") && report.contains("**Interpreter: nothing said.**"), "{report}");
|
||||
assert!(report.contains("| claude-sonnet-5-5 | 12 | 120 | 24 |"), "twelve calls, three a case, in the footer: {report}");
|
||||
assert_eq!(std::fs::read_dir(dir.path()).unwrap().count(), 1, "the batch wrote nothing; the caller writes the report");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,43 @@
|
|||
//! The Interpreter's speech (map section 4, cut C3b): what she says aloud, decided from her prose by one tool-less
|
||||
//! structured model call, and held by code to her prose.
|
||||
//! The Interpreter's speech (map section 4, cut C3b): what she says aloud this turn, decided from her prose by one
|
||||
//! tool-less structured model call, and built by code from her own words.
|
||||
//!
|
||||
//! The Persona writes her thought; she does not mark speech. The Interpreter reads her prose against the stimulus and
|
||||
//! proposes zero or more lines, each with its room, its explicit addressees (Matrix mentions and a reply target, as
|
||||
//! structured fields, never `@` text) and the verbatim span of her prose the line rests on. Code then keeps a line only
|
||||
//! when:
|
||||
//! - its span is in her prose, located by Ghostlight's `SourceSpan::locate` (map 4.3: a quote not in the prose word for
|
||||
//! word binds nothing);
|
||||
//! - its room is one she may speak in this turn;
|
||||
//! - its words are not someone else's: a line whose text is what she heard is a recollection, never her speech;
|
||||
//! - its mentions and reply target name people the packet showed her; any other is dropped, and the drop recorded.
|
||||
//! 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.
|
||||
//!
|
||||
//! Everything refused is reported with its reason. Nothing here posts: the commit (C3c) will.
|
||||
//! 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.
|
||||
|
||||
use ghostlight_persona_projection::{InterpreterPrompt, SourceSpan, build_interpreter_prompt};
|
||||
use ghostlight_persona_projection::SourceSpan;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::narrate::{Model, lived_stream};
|
||||
use super::narrate::{Model, heard_overlap, lived_stream};
|
||||
use super::select::Packet;
|
||||
use super::tuning::Tuning;
|
||||
|
||||
/// The contract the model answers in: one JSON object, nothing around it.
|
||||
pub(crate) const SPEECH_CONTRACT: &str = r#"{"say": [{"room": "<a room from the rooms listed>", "text": "<the words she types, in her voice, no @handles>", "mentions": ["<Matrix id of someone listed whom she addresses directly>"], "reply_to": "<Matrix id of the person whose message she answers, or null>", "source_quote": "<the exact words of her prose this line rests on, copied character for character>"}], "gaps": [{"kind": "ambiguity | missing_reference | unresolved", "source_quote": "<exact words of her prose>", "detail": "<why>"}]}"#;
|
||||
/// 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;
|
||||
|
||||
/// 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.
|
||||
|
||||
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>\"}]}
|
||||
|
||||
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.";
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Answer {
|
||||
|
|
@ -35,113 +50,111 @@ struct Answer {
|
|||
#[derive(Debug, Deserialize)]
|
||||
struct Proposed {
|
||||
#[serde(default)]
|
||||
room: String,
|
||||
#[serde(default)]
|
||||
text: String,
|
||||
spans: Vec<String>,
|
||||
#[serde(default)]
|
||||
mentions: Vec<String>,
|
||||
#[serde(default)]
|
||||
reply_to: Option<String>,
|
||||
#[serde(default)]
|
||||
source_quote: String,
|
||||
}
|
||||
|
||||
/// What the Interpreter is told beside Ghostlight's membrane: this step's scope, its rules, and that it has no tools.
|
||||
fn guidance(tuning: &Tuning) -> String {
|
||||
tuning.interpreter.guidance.trim().to_owned()
|
||||
}
|
||||
|
||||
/// The typed context the Interpreter may act on: the rooms she may speak in and the people she may address, by id.
|
||||
fn typed_context(packet: &Packet) -> String {
|
||||
let mut out = format!("Rooms she may speak in: {}\n", packet.rooms.join("; "));
|
||||
out.push_str("People she may address, as label \u{2014} Matrix id:\n");
|
||||
pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str) -> String {
|
||||
let mut people = String::new();
|
||||
for (label, id) in &packet.people {
|
||||
out.push_str(&format!("- {label} \u{2014} {id}\n"));
|
||||
people.push_str(&format!("- {label} \u{2014} {id}\n"));
|
||||
}
|
||||
out.push_str(&format!("\nWhat reached her this turn:\n{}", packet.stimulus));
|
||||
out
|
||||
}
|
||||
|
||||
pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tuning: &Tuning) -> String {
|
||||
build_interpreter_prompt(&InterpreterPrompt {
|
||||
identity: &packet.identity,
|
||||
typed_context: &typed_context(packet),
|
||||
lived_stream: &lived_stream(narration, &packet.heard),
|
||||
persona_output: prose,
|
||||
output_schema: Some(SPEECH_CONTRACT),
|
||||
domain_guidance: &guidance(tuning),
|
||||
})
|
||||
if people.is_empty() {
|
||||
people.push_str("- no one else has spoken here lately\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}",
|
||||
packet.identity,
|
||||
packet.room.as_deref().unwrap_or("none"),
|
||||
packet.room_kind.words(),
|
||||
packet.stimulus,
|
||||
lived_stream(narration, &packet.heard),
|
||||
)
|
||||
}
|
||||
|
||||
/// The model's answer as JSON: the object itself, or inside a fenced block.
|
||||
fn json_of(text: &str) -> Option<Answer> {
|
||||
let trimmed = text.trim();
|
||||
let body = trimmed.strip_prefix("```json").or_else(|| trimmed.strip_prefix("```")).map_or(trimmed, |inner| inner.trim_end_matches("```")).trim();
|
||||
let start = body.find('{')?;
|
||||
let end = body.rfind('}')?;
|
||||
serde_json::from_str(&body[start..=end]).ok()
|
||||
let start = text.find('{')?;
|
||||
let end = text.rfind('}')?;
|
||||
serde_json::from_str(&text[start..=end]).ok()
|
||||
}
|
||||
|
||||
/// Whitespace-folded, lowercased, outer quotation marks off: how two texts are compared for being the same words.
|
||||
fn folded(text: &str) -> String {
|
||||
text.trim().trim_matches(|c: char| matches!(c, '"' | '\'' | '\u{201C}' | '\u{201D}' | '\u{2018}' | '\u{2019}')).split_whitespace().collect::<Vec<_>>().join(" ").to_lowercase()
|
||||
/// The line her cited spans make: each located in her prose after the one before it, joined with one space; or why not.
|
||||
fn built(prose: &str, spans: &[String]) -> Result<(String, Vec<Value>), &'static str> {
|
||||
let mut from = 0;
|
||||
let mut words = Vec::new();
|
||||
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());
|
||||
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");
|
||||
}
|
||||
Ok((words.join(" "), located))
|
||||
}
|
||||
|
||||
/// Whether a line is someone else's words: its text, folded, is inside what she heard. A narrow guard on a recollection
|
||||
/// posted as speech, not a reading of meaning: the model decides what she means to say.
|
||||
fn recollection(text: &str, heard: &str) -> bool {
|
||||
let line = folded(text);
|
||||
!line.is_empty() && folded(heard).contains(&line)
|
||||
/// 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.
|
||||
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
|
||||
}
|
||||
|
||||
/// One speech decision: the Interpreter's call, then code's hold on each line. The report carries the said lines, the
|
||||
/// refused ones with their reasons, the model's gaps and the call's usage; a failed call or an answer that is not the
|
||||
/// contract is a failure, never a silence.
|
||||
/// 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.
|
||||
pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narration: &str, prose: &str, tuning: &Tuning) -> Value {
|
||||
let answer = match model.ask(request_id, &tuning.interpreter.model, &speech_prompt(packet, narration, prose, tuning)) {
|
||||
let answer = match model.ask(request_id, &tuning.interpreter.model, &speech_prompt(packet, narration, prose)) {
|
||||
Ok(answer) => answer,
|
||||
Err(failed) => return json!({ "failed": failed.reason, "usage": failed.usage }),
|
||||
};
|
||||
let Some(parsed) = json_of(&answer.text) else {
|
||||
return json!({ "failed": "the answer is not the speech contract's JSON", "raw": answer.text, "usage": answer.usage });
|
||||
};
|
||||
let known = |id: &str| packet.people.iter().any(|(_, person)| person == id);
|
||||
let mut said = Vec::new();
|
||||
let Some(room) = packet.room.clone() else {
|
||||
return json!({ "said": [], "refused": [{ "why": "the turn has no room to speak in" }], "gaps": parsed.gaps, "usage": answer.usage });
|
||||
};
|
||||
let shown = |id: &str| packet.people.iter().any(|(_, person)| person == id);
|
||||
let mut said: Vec<Value> = Vec::new();
|
||||
let mut refused = Vec::new();
|
||||
for line in parsed.say {
|
||||
let text = line.text.trim().to_owned();
|
||||
let why = if text.is_empty() {
|
||||
Some("no words")
|
||||
} else if !packet.rooms.contains(&line.room) {
|
||||
Some("not a room she may speak in this turn")
|
||||
} else if recollection(&text, &packet.heard) {
|
||||
Some("someone else's words: a recollection, not her speech")
|
||||
let (text, spans) = match built(prose, &line.spans) {
|
||||
Ok(built) => built,
|
||||
Err(why) => {
|
||||
refused.push(json!({ "spans": line.spans, "why": why }));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let why = if echo(&text, &packet.bodies) {
|
||||
Some("mostly words she heard: an echo, not her speech")
|
||||
} else if said.iter().any(|kept| kept["text"] == text.as_str()) {
|
||||
Some("the same line again")
|
||||
} else if said.len() >= MAX_LINES {
|
||||
Some("past the lines one turn may say")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let span = SourceSpan::locate(prose, line.source_quote.trim());
|
||||
let why = why.or_else(|| span.is_none().then_some("its source quote is not in her prose word for word"));
|
||||
if let Some(why) = why {
|
||||
refused.push(json!({ "text": text, "room": line.room, "source_quote": line.source_quote, "why": why }));
|
||||
refused.push(json!({ "text": text, "why": why }));
|
||||
continue;
|
||||
}
|
||||
let span = span.unwrap_or_else(|| SourceSpan::whole(prose));
|
||||
let (mentions, unknown): (Vec<String>, Vec<String>) = line.mentions.into_iter().partition(|id| known(id));
|
||||
let (mentions, unknown): (Vec<String>, Vec<String>) = line.mentions.into_iter().partition(|id| shown(id));
|
||||
let (reply_to, unknown_reply) = match line.reply_to.filter(|id| !id.trim().is_empty()) {
|
||||
Some(id) if known(&id) => (Some(id), None),
|
||||
Some(id) if shown(&id) => (Some(id), None),
|
||||
Some(id) => (None, Some(id)),
|
||||
None => (None, None),
|
||||
};
|
||||
said.push(json!({
|
||||
"room": line.room,
|
||||
"text": text,
|
||||
"mentions": mentions,
|
||||
"reply_to": reply_to,
|
||||
"rests_on": { "quote": span.verbatim(), "start_byte": span.start_byte(), "end_byte": span.end_byte() },
|
||||
"dropped": { "mentions": unknown, "reply_to": unknown_reply },
|
||||
}));
|
||||
said.push(json!({ "room": room, "text": text, "mentions": mentions, "reply_to": reply_to, "rests_on": spans, "dropped": { "mentions": unknown, "reply_to": unknown_reply } }));
|
||||
}
|
||||
json!({ "said": said, "refused": refused, "gaps": parsed.gaps, "usage": answer.usage })
|
||||
json!({ "room": room, "room_kind": packet.room_kind, "said": said, "refused": refused, "gaps": parsed.gaps, "usage": answer.usage })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -2,26 +2,28 @@ use serde_json::json;
|
|||
|
||||
use super::*;
|
||||
use crate::projection::harness::tests::{Scripted, control};
|
||||
use crate::projection::select::{History, Inputs, People, Room, RoomLine, TurnKind, select};
|
||||
use crate::projection::select::{History, Inputs, People, Room, RoomKind, RoomLine, TurnKind, select};
|
||||
use crate::projection::tuning::Tuning;
|
||||
|
||||
const HER: &str = "@heimdall:gamecult.org";
|
||||
const NIBU: &str = "@nibu:gamecult.org";
|
||||
const VOID: &str = "@void:gamecult.org";
|
||||
const MINDS: &str = "#minds:gamecult.org";
|
||||
|
||||
/// The round Soul probed: Nibu said "least built part" and greeted with "@nibu"; this is Heimdall's turn.
|
||||
/// 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.".into(), at_ms: at, to_her: false },
|
||||
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 },
|
||||
],
|
||||
here: Some(MINDS.into()),
|
||||
..Room::default()
|
||||
};
|
||||
let minds = vec![HER.to_owned(), NIBU.to_owned()];
|
||||
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();
|
||||
|
|
@ -29,53 +31,80 @@ fn packet() -> Packet {
|
|||
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())
|
||||
}
|
||||
|
||||
fn decided(prose: &str, answer: serde_json::Value) -> Value {
|
||||
let reply = answer.to_string();
|
||||
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())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_recollection_is_never_her_speech() {
|
||||
let prose = "Nibu's 'least built part' snags. I turn it over and say nothing.";
|
||||
let answer = json!({ "say": [{ "room": MINDS, "text": "least built part", "source_quote": "least built part", "mentions": [], "reply_to": null }] });
|
||||
let decision = decided(prose, answer);
|
||||
assert_eq!(decision["said"], json!([]), "{decision}");
|
||||
assert!(decision["refused"][0]["why"].as_str().unwrap().contains("recollection"), "{decision}");
|
||||
fn texts(decision: &Value) -> Vec<String> {
|
||||
decision["said"].as_array().unwrap().iter().map(|line| line["text"].as_str().unwrap().to_owned()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn i_say_nothing_says_nothing() {
|
||||
let decision = decided("I say nothing. The quiet is fine.", json!({ "say": [] }));
|
||||
assert_eq!((decision["said"].as_array().map(Vec::len), decision["refused"].as_array().map(Vec::len)), (Some(0), Some(0)));
|
||||
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}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_quoted_handle_is_no_mention() {
|
||||
// Her "@nibu" is a greeting: even if the model posts it, its text carries no mention, and the quote of Meta's line
|
||||
// is someone else's words.
|
||||
let prose = "Her \"@nibu\" is a greeting, not mine to answer.";
|
||||
let echoed = decided(prose, json!({ "say": [{ "room": MINDS, "text": "@nibu", "source_quote": "@nibu", "mentions": [], "reply_to": null }] }));
|
||||
assert_eq!(echoed["said"], json!([]), "the handle is Meta's words: {echoed}");
|
||||
let posted = decided(prose, json!({ "say": [{ "room": MINDS, "text": "@nibu is a greeting", "source_quote": "is a greeting", "mentions": [], "reply_to": null }] }));
|
||||
assert_eq!(posted["said"][0]["mentions"], json!([]), "only the structured field mentions anyone: {posted}");
|
||||
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}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_rests_on_her_prose_in_a_room_she_may_speak_in_and_names_only_people_shown() {
|
||||
let prose = "I'd like Nibu to know the economy can wait. I tell her so.";
|
||||
let answer = json!({ "say": [
|
||||
{ "room": MINDS, "text": "the economy can wait", "source_quote": "I tell her so", "mentions": [NIBU, "@stranger:x"], "reply_to": NIBU },
|
||||
{ "room": MINDS, "text": "hello", "source_quote": "words she never wrote", "mentions": [], "reply_to": null },
|
||||
{ "room": "#elsewhere:gamecult.org", "text": "hi there", "source_quote": "I tell her so", "mentions": [], "reply_to": null },
|
||||
] });
|
||||
let decision = decided(prose, answer);
|
||||
let said = &decision["said"];
|
||||
assert_eq!(said.as_array().unwrap().len(), 1, "{decision}");
|
||||
assert_eq!((said[0]["mentions"].clone(), said[0]["reply_to"].clone(), said[0]["rests_on"]["quote"].clone()), (json!([NIBU]), json!(NIBU), json!("I tell her so")));
|
||||
assert_eq!(said[0]["dropped"]["mentions"], json!(["@stranger:x"]), "an unknown id is dropped and recorded");
|
||||
let whys: Vec<&str> = decision["refused"].as_array().unwrap().iter().filter_map(|line| line["why"].as_str()).collect();
|
||||
assert!(whys.iter().any(|why| why.contains("not in her prose")) && whys.iter().any(|why| why.contains("not a room")), "{whys:?}");
|
||||
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}");
|
||||
}
|
||||
|
||||
#[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"]);
|
||||
}
|
||||
|
||||
#[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}");
|
||||
}
|
||||
|
||||
#[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 }]));
|
||||
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 prose = "One. Two. Three.";
|
||||
let three = decided(prose, json!([{ "spans": ["One."] }, { "spans": ["Two."] }, { "spans": ["Three."] }]));
|
||||
assert_eq!(texts(&three), ["One.", "Two."], "{three}");
|
||||
}
|
||||
|
||||
#[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.
|
||||
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}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -88,11 +117,13 @@ fn an_answer_that_is_not_the_contract_is_a_failure_not_a_silence() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn the_prompt_carries_her_prose_the_rooms_and_the_people_by_id_and_the_rules() {
|
||||
let prompt = speech_prompt(&packet(), "The room is warm.", "I say nothing.", &Tuning::default());
|
||||
assert!(prompt.contains(":interpreter -->") && prompt.ends_with("I say nothing."), "Ghostlight's Interpreter membrane, her prose last");
|
||||
assert!(prompt.contains("Rooms she may speak in: #minds:gamecult.org") && prompt.contains(NIBU) && prompt.contains("People she may address"), "{prompt}");
|
||||
for rule in ["never her speech", "is not speech", "character for character", "No tool is available"] {
|
||||
fn the_prompt_is_hugins_chat_prompt_with_the_room_its_kind_and_who_is_in_it() {
|
||||
let packet = packet();
|
||||
assert_eq!((packet.room.as_deref(), packet.room_kind), (Some(MINDS), RoomKind::Public));
|
||||
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"] {
|
||||
assert!(prompt.contains(rule), "{rule}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,29 @@ pub(crate) struct Room {
|
|||
/// When she last heard from people, by Matrix id, beyond what the tail shows: a fixture's table (`mind-persona project
|
||||
/// --room`). The live turn has none yet; the tail is its only source.
|
||||
pub last_heard: Vec<(String, u64)>,
|
||||
/// The rooms the mouth called direct messages (a delivery's `is_direct`), by the key the lines carry.
|
||||
pub direct: Vec<String>,
|
||||
/// The rooms that are hers, by key: the caller's (a simulation's plan); the live body records none yet.
|
||||
pub own: Vec<String>,
|
||||
}
|
||||
|
||||
/// Who a room's audience is, for what she may say there: a direct message, a room of her own, or a public room.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum RoomKind {
|
||||
Direct,
|
||||
Own,
|
||||
Public,
|
||||
}
|
||||
|
||||
impl RoomKind {
|
||||
pub(crate) fn words(self) -> &'static str {
|
||||
match self {
|
||||
Self::Direct => "a direct message",
|
||||
Self::Own => "her own room, open to its members",
|
||||
Self::Public => "a public room",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One thing she said, from the trace.
|
||||
|
|
@ -222,10 +245,13 @@ pub(crate) struct Packet {
|
|||
/// Her pronouns, for the words the prompts speak of her in.
|
||||
#[serde(skip)]
|
||||
pub forms: Forms,
|
||||
/// Whom the Interpreter may mention or reply to: (label, Matrix id).
|
||||
/// Whom she may mention or reply to: the people this packet showed her from the room, (label, Matrix id).
|
||||
pub people: Vec<(String, String)>,
|
||||
/// Where she may speak this turn: the turn's room, or the rooms the messages to her and around her came from.
|
||||
pub rooms: Vec<String>,
|
||||
/// The one room she may speak in this turn, and its kind.
|
||||
pub room: Option<String>,
|
||||
pub room_kind: RoomKind,
|
||||
/// The bodies of the messages she heard this turn, without speakers or rooms: what an echo is measured against.
|
||||
pub bodies: Vec<String>,
|
||||
}
|
||||
|
||||
/// What the messages to her cost past the caps: bytes over the stimulus and heard caps, the older messages to her the
|
||||
|
|
@ -481,6 +507,12 @@ fn candidates(inputs: &Inputs, tuning: &Tuning, present: &BTreeSet<String>, touc
|
|||
if body.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let person = text(memory, &["target", "id"]).to_lowercase();
|
||||
let about_someone = text(memory, &["target", "kind"]) == "person" && !person.is_empty();
|
||||
let body = match privately(inputs, &person) {
|
||||
Some(forms) if about_someone => format!("{} knows privately: {body}", forms.subj),
|
||||
_ => body,
|
||||
};
|
||||
let line = format!("- memory [{}]: {}", text(memory, &["id"]), clip(&one_line(&body), item_bytes));
|
||||
let salience = number(memory, &["intensity"]).unwrap_or(SALIENCE_UNSTATED);
|
||||
// Only the day's short-term items fade; a crystallized memory comes forward by what the room touches.
|
||||
|
|
@ -813,7 +845,7 @@ fn present_people(inputs: &Inputs, tuning: &Tuning) -> Vec<(String, String)> {
|
|||
|
||||
/// A bond line: the person, the kind of bond after a dash (a label may hold a comma: "Meta, the operator"), trust and
|
||||
/// friction as words when the bond carries them, and its summary. What the bond does not carry is left out.
|
||||
fn bond_line(bond: &Value, name: &str, tuning: &Tuning) -> String {
|
||||
fn bond_line(bond: &Value, name: &str, tuning: &Tuning, private: Option<Forms>) -> String {
|
||||
let feel: Vec<&str> = [number(bond, &["trust"]).map(trust_words), number(bond, &["tension"]).map(friction_words)].into_iter().flatten().collect();
|
||||
let custom = text(bond, &["customRelationshipKind"]);
|
||||
let kind = clip(&one_line(if custom.is_empty() { text(bond, &["relationshipKind"]) } else { custom }), NAME_BYTES);
|
||||
|
|
@ -822,6 +854,10 @@ fn bond_line(bond: &Value, name: &str, tuning: &Tuning) -> String {
|
|||
let _ = write!(line, " \u{2014} {kind}");
|
||||
}
|
||||
let summary = clip(&one_line(text(bond, &["summary"])), tuning.select.bond_summary_bytes);
|
||||
let summary = match private {
|
||||
Some(forms) if !summary.is_empty() => format!("{} knows privately: {summary}", forms.cap_subj),
|
||||
_ => summary,
|
||||
};
|
||||
match (feel.is_empty(), summary.is_empty()) {
|
||||
(true, true) => {}
|
||||
(true, false) => {
|
||||
|
|
@ -893,9 +929,25 @@ fn names_of(line: &RoomLine, inputs: &Inputs) -> Vec<String> {
|
|||
/// once, oldest first. The room is the turn's when it is one room; otherwise the room of the newest message to her, else
|
||||
/// of the newest message, else of the newest tail line. Never several rooms folded into one, so a direct message is
|
||||
/// only ever read as its own room.
|
||||
fn recent_lines<'a>(inputs: &'a Inputs) -> Vec<&'a RoomLine> {
|
||||
/// The turn's room: the one it is in when it is one room; otherwise the room of the newest message to her, else of the
|
||||
/// newest message, else of the newest tail line. Where the packet describes and the only room she may speak in.
|
||||
pub(crate) fn turn_room<'a>(inputs: &'a Inputs) -> Option<&'a str> {
|
||||
let newest = |lines: &'a [RoomLine], keep: &dyn Fn(&RoomLine) -> bool| lines.iter().filter(|line| keep(line)).max_by_key(|line| line.at_ms).map(|line| line.room.as_str());
|
||||
let Some(room) = inputs.room.here.as_deref().or_else(|| newest(&inputs.room.messages, &|line| line.to_her)).or_else(|| newest(&inputs.room.messages, &|_| true)).or_else(|| newest(&inputs.room.tail, &|_| true)) else {
|
||||
inputs.room.here.as_deref().or_else(|| newest(&inputs.room.messages, &|line| line.to_her)).or_else(|| newest(&inputs.room.messages, &|_| true)).or_else(|| newest(&inputs.room.tail, &|_| true))
|
||||
}
|
||||
|
||||
fn room_kind(inputs: &Inputs, room: &str) -> RoomKind {
|
||||
if inputs.room.direct.iter().any(|direct| direct == room) {
|
||||
RoomKind::Direct
|
||||
} else if inputs.room.own.iter().any(|own| own == room) {
|
||||
RoomKind::Own
|
||||
} else {
|
||||
RoomKind::Public
|
||||
}
|
||||
}
|
||||
|
||||
fn recent_lines<'a>(inputs: &'a Inputs) -> Vec<&'a RoomLine> {
|
||||
let Some(room) = turn_room(inputs) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut lines: Vec<&RoomLine> = Vec::new();
|
||||
|
|
@ -1008,38 +1060,22 @@ fn pronoun_line(inputs: &Inputs, tuning: &Tuning) -> Option<String> {
|
|||
(!parts.is_empty()).then(|| clip(&format!("- pronouns: {}", parts.join("; ")), ALSO_HERE_BYTES))
|
||||
}
|
||||
|
||||
/// Whether what she knows of `person` (a bond's or memory's id) is framed as known privately here: everywhere but a
|
||||
/// direct message with that person. Structural, never a reading of the fact: whether a line fits its audience stays the
|
||||
/// Interpreter's judgement. Her pronouns when it is.
|
||||
fn privately(inputs: &Inputs, person: &str) -> Option<Forms> {
|
||||
let room = turn_room(inputs)?;
|
||||
let partner = room_kind(inputs, room) == RoomKind::Direct && inputs.room.messages.iter().chain(&inputs.room.tail).any(|line| line.room == room && inputs.people.person_of(&line.sender) == person);
|
||||
(!partner).then(|| forms(inputs.state))
|
||||
}
|
||||
|
||||
/// A part as a sentence: its first letter upper-cased, a full stop after it.
|
||||
fn sentence(part: &str) -> String {
|
||||
let mut chars = part.chars();
|
||||
chars.next().map_or_else(String::new, |first| format!("{}{}.", first.to_uppercase(), chars.as_str()))
|
||||
}
|
||||
|
||||
/// Whom the Interpreter may address: everyone the packet shows from the room, then the swarm's other Minds, who are in
|
||||
/// her rooms whether or not they spoke; a Mind she is bound to goes by the bond's label, any other by the id alone.
|
||||
fn addressable(inputs: &Inputs, tuning: &Tuning) -> Vec<(String, String)> {
|
||||
let mut people = people_in_view(inputs, tuning);
|
||||
for mind in inputs.people.minds.iter().filter(|mind| *mind != inputs.people.own_sender) {
|
||||
if !people.iter().any(|(_, id)| id == mind) {
|
||||
people.push((bond_label(inputs, mind).unwrap_or_else(|| mind.clone()), mind.clone()));
|
||||
}
|
||||
}
|
||||
people
|
||||
}
|
||||
|
||||
fn speaking_rooms(inputs: &Inputs) -> Vec<String> {
|
||||
let mut rooms: Vec<String> = inputs.room.here.iter().cloned().collect();
|
||||
for line in &inputs.room.messages {
|
||||
if !rooms.contains(&line.room) {
|
||||
rooms.push(line.room.clone());
|
||||
}
|
||||
}
|
||||
if rooms.is_empty()
|
||||
&& let Some(line) = recent_lines(inputs).last()
|
||||
{
|
||||
rooms.push(line.room.clone());
|
||||
}
|
||||
rooms
|
||||
}
|
||||
|
||||
/// The pronouns of a person nobody listed.
|
||||
const UNKNOWN_PRONOUNS: &str = "they/them";
|
||||
|
|
@ -1076,7 +1112,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
for (id, name) in &present {
|
||||
match bonds.iter().find(|bond| live(bond) && text(bond, &["object", "id"]).to_lowercase() == *id) {
|
||||
Some(bond) if full < tuning.select.people_full => {
|
||||
let line = bond_line(bond, name, tuning);
|
||||
let line = bond_line(bond, name, tuning, privately(inputs, id));
|
||||
if used + line.len() < budget {
|
||||
full += 1;
|
||||
used += line.len() + 1;
|
||||
|
|
@ -1139,5 +1175,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
lines.extend(taken.iter().map(|candidate| candidate.line.clone()));
|
||||
ids.extend(taken.iter().map(|candidate| candidate.id.clone()));
|
||||
let selected = taken.into_iter().map(|candidate| Pick { id: candidate.id, pool: candidate.pool, log_score: candidate.log_score }).collect();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, identity, context: lines.join("\n"), stimulus, heard, overflow, present: present_names, ids, selected, forms: forms(inputs.state), people: addressable(inputs, tuning), rooms: speaking_rooms(inputs) }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, identity, context: lines.join("\n"), stimulus, heard, overflow, present: present_names, ids, selected, forms: forms(inputs.state), people: people_in_view(inputs, tuning), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies: inputs.room.messages.iter().map(|line| line.text.clone()).collect() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,15 +151,24 @@ fn speaker(line: &Line, member: &Member, operators: &[String], cast: &[String])
|
|||
}
|
||||
}
|
||||
|
||||
/// For each line, how many Mind lines in a row came before it in its room since a human last spoke there.
|
||||
/// For each line, how many Mind lines in a row came before it in her current Mind-only run: one run across every room
|
||||
/// she sees, which a human's line ends only when it is in a room the run has lines in. Meta chatting in #eureka does not
|
||||
/// end a loop in #minds.
|
||||
fn mind_runs(lines: &[Line], cast: &[String], member: &Member) -> Vec<usize> {
|
||||
let mut run = 0usize;
|
||||
let mut run_rooms: Vec<&str> = Vec::new();
|
||||
lines
|
||||
.iter()
|
||||
.map(|line| {
|
||||
let before = run;
|
||||
if line.visible_to(&member.entry.id, &member.rooms) {
|
||||
run = if cast.contains(&line.from) { run + 1 } else { 0 };
|
||||
if cast.contains(&line.from) {
|
||||
run += 1;
|
||||
run_rooms.push(&line.room);
|
||||
} else if run_rooms.contains(&line.room.as_str()) {
|
||||
run = 0;
|
||||
run_rooms.clear();
|
||||
}
|
||||
}
|
||||
before
|
||||
})
|
||||
|
|
@ -183,12 +192,13 @@ fn how_addressed(line: &Line, at: usize, member: &Member, lines: &[Line]) -> &'s
|
|||
/// it, the strongest evidence that addressed her and the lines that did.
|
||||
struct Woken {
|
||||
cause: WakeCause,
|
||||
/// The newest line with that cause: its room is the turn's room.
|
||||
line: usize,
|
||||
how: Option<&'static str>,
|
||||
by: Vec<Value>,
|
||||
}
|
||||
|
||||
/// Whether she spoke in the exchange a line continues: walking back through the lines of its room while each is within
|
||||
/// `gap` of the one after it.
|
||||
/// Whether she is in the exchange a line belongs to: she spoke in its room within `window` before it.
|
||||
fn in_exchange(lines: &[Line], at: usize, her: &str, window: Duration) -> bool {
|
||||
let line = &lines[at];
|
||||
let since = line.at_ms.saturating_sub(u64::try_from(window.num_milliseconds()).unwrap_or(0));
|
||||
|
|
@ -209,14 +219,15 @@ fn woken(lines: &[Line], runs: &[usize], seen: usize, member: &Member, operators
|
|||
}
|
||||
}
|
||||
let cause = found.iter().map(|(_, cause)| *cause).min()?;
|
||||
let line = found.iter().rev().find(|(_, found)| *found == cause).map_or(0, |(at, _)| *at);
|
||||
if cause != WakeCause::AddressedByMind {
|
||||
return Some(Woken { cause, how: None, by: vec![] });
|
||||
return Some(Woken { cause, line, how: None, by: vec![] });
|
||||
}
|
||||
let addressing: Vec<usize> = found.iter().filter(|(_, cause)| *cause == WakeCause::AddressedByMind).map(|(at, _)| *at).collect();
|
||||
let rank = |how: &str| ["mention or reply", "id as text", "name in text"].iter().position(|one| *one == how).unwrap_or(3);
|
||||
let how = addressing.iter().map(|at| how_addressed(&lines[*at], *at, member, lines)).min_by_key(|how| rank(how));
|
||||
let by = addressing.iter().map(|at| json!({ "from": lines[*at].from, "how": how_addressed(&lines[*at], *at, member, lines), "says": lines[*at].says })).collect();
|
||||
Some(Woken { cause, how, by })
|
||||
Some(Woken { cause, line, how, by })
|
||||
}
|
||||
|
||||
/// The wire spelling of a cause, and of the beat.
|
||||
|
|
@ -348,7 +359,8 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
let member = &members[at];
|
||||
let id = member.entry.id.clone();
|
||||
let fresh: Vec<&Line> = lines[seen[at]..].iter().filter(|line| line.from != id && line.visible_to(&id, &member.rooms)).collect();
|
||||
let woke_on = fresh.iter().rev().find(|line| line.mentions.contains(&id) || line.dm_to.as_deref() == Some(id.as_str())).or(fresh.last()).copied();
|
||||
// The turn is in the room of the line that woke her; a beat's, in the room of the newest line she has not seen.
|
||||
let woke_on = why.as_ref().map(|why| &lines[why.line]).or(fresh.last().copied());
|
||||
let here = woke_on.map_or_else(|| member.rooms[0].clone(), |line| line.room.clone());
|
||||
// Woken by a direct message, she answers in it: to its sender alone.
|
||||
let dm_to = woke_on.filter(|line| line.dm_to.as_deref() == Some(id.as_str())).map(|line| line.from.clone());
|
||||
|
|
@ -369,6 +381,7 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
through: Through::Interpreter,
|
||||
last_heard: vec![],
|
||||
recent: recent[at].clone(),
|
||||
own_rooms: member.entry.own_rooms.clone(),
|
||||
};
|
||||
let view = View { lines: &lines, viewer: &id, rooms: &member.rooms, seen: seen[at] };
|
||||
let names = Names(&member.addressee);
|
||||
|
|
@ -556,8 +569,8 @@ fn policy_words(policy: WakePolicy) -> String {
|
|||
match policy {
|
||||
WakePolicy::Live => "live: the operator or another Mind addressing her (the heartbeat's rule today)".into(),
|
||||
WakePolicy::Ruled => "ruled: a line addressing her, from anyone, and any human line in her rooms".into(),
|
||||
WakePolicy::HumansPace(cap) => format!("humans_pace (cap {cap}): a human's line wakes a Mind in her own room always, and in a public room when it addresses her or continues an exchange she is in; a Mind's line wakes another only by an explicit mention or a reply, while fewer than {cap} Mind lines in a row came before it in its room, never by a name in prose"),
|
||||
WakePolicy::NamesWithCap(cap) => format!("names_with_cap {cap}: ruled, but a Mind's line past {cap} Mind lines in a row in its room wakes no one until a human speaks"),
|
||||
WakePolicy::HumansPace(cap) => format!("humans_pace (cap {cap}): a human's line wakes a Mind in her own room always, and in a public room when it addresses her or continues an exchange she is in; a Mind's line wakes another only by an explicit mention or a reply, while her current Mind-only run, across her rooms, is under {cap} lines, never by a name in prose"),
|
||||
WakePolicy::NamesWithCap(cap) => format!("names_with_cap {cap}: ruled, but a Mind's line wakes no one once her current Mind-only run, across her rooms, has {cap} lines, until a human speaks where it runs"),
|
||||
WakePolicy::AllMessages => "all_messages: any line in her rooms, a Mind's too (the old loop, the control)".into(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,27 +243,34 @@ fn a_seed_replays_its_order_and_another_seed_changes_it() {
|
|||
fn tagging(mention: bool) -> Scripted {
|
||||
let mentions = if mention { json!([LIBBY]) } else { json!([]) };
|
||||
Scripted::new(|prompt| if is_tobiah(prompt) { "\"ask @libby:gamecult.org, and Libby too\"".into() } else { "She lets it be.".into() }).interpreting(move |prompt| {
|
||||
if !prompt.contains("Identity:\nTobiah") {
|
||||
if !prompt.contains("Who she is:\nTobiah") {
|
||||
return json!({ "say": [] }).to_string();
|
||||
}
|
||||
json!({ "say": [{ "room": "#minds:gamecult.org", "text": "ask @libby:gamecult.org, and Libby too", "source_quote": "ask @libby:gamecult.org, and Libby too", "mentions": mentions, "reply_to": null }] }).to_string()
|
||||
json!({ "say": [{ "spans": ["ask @libby:gamecult.org, and Libby too"], "mentions": mentions, "reply_to": null }] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_the_interpreters_structured_mention_is_a_mention_and_an_at_in_the_text_is_not() {
|
||||
// Libby says hello first, so the packet shows her to Tobiah: a mention reaches only someone shown.
|
||||
let hello = "[[message]]\nround = 0\nfrom = \"@libby:gamecult.org\"\nname = \"Libby\"\nroom = \"#minds:gamecult.org\"\nsays = \"hello all\"\n";
|
||||
let plan = |dir: &Path, wake: &str, rounds: usize| {
|
||||
let path = plan(dir, wake, rounds, "");
|
||||
std::fs::write(&path, format!("{}{hello}", std::fs::read_to_string(&path).unwrap())).unwrap();
|
||||
path
|
||||
};
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let (_, plain) = run_plan(&plan(dir.path(), "\"ruled\"", 3, ""), &tagging(false));
|
||||
let (_, plain) = run_plan(&plan(dir.path(), "\"ruled\"", 3), &tagging(false));
|
||||
let addressed = &plain["metrics"]["mind_addressed_wakes"];
|
||||
assert_eq!(addressed["mention_or_reply"].as_u64(), Some(0), "an @id in the words tags no one: {addressed}");
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let (_, tagged) = run_plan(&plan(dir.path(), "\"ruled\"", 3, ""), &tagging(true));
|
||||
let (_, tagged) = run_plan(&plan(dir.path(), "\"ruled\"", 3), &tagging(true));
|
||||
let addressed = &tagged["metrics"]["mind_addressed_wakes"];
|
||||
let libby_mind_wakes = turns(&tagged).iter().filter(|(_, who, why)| who == "Libby" && why == "addressed_by_mind").count();
|
||||
assert_eq!(addressed["mention_or_reply"].as_u64().unwrap() as usize, libby_mind_wakes, "{addressed}");
|
||||
// Under humans_pace a name or an @ in the words wakes no one; the structured mention does.
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = plan(dir.path(), "{ humans_pace = 4 }", 3, "");
|
||||
let path = plan(dir.path(), "{ humans_pace = 4 }", 3);
|
||||
let opening = "says = \"good afternoon, everyone\"\n";
|
||||
std::fs::write(&path, std::fs::read_to_string(&path).unwrap().replace(opening, &format!("{opening}mentions = [\"{TOBIAH}\"]\n"))).unwrap();
|
||||
let woken_libby = |model: &Scripted| turns(&run_plan(&path, model).1).iter().any(|(_, who, _)| who == "Libby");
|
||||
|
|
@ -284,14 +291,18 @@ fn a_direct_message_in_one_of_the_plans_rooms_is_refused() {
|
|||
|
||||
#[test]
|
||||
fn the_mind_run_is_counted_across_her_rooms_and_an_uncounted_run_is_at_the_cap() {
|
||||
let her = Member { names_from: "test", addressee: Addressee::new(LIBBY, ["libby"]), entry: CastEntry { id: LIBBY.into(), name: "Libby".into(), state: PathBuf::new(), rooms: vec![], own_rooms: vec![] }, state: Value::Null, rooms: vec!["#a:x".into(), "#b:x".into()] };
|
||||
let cast = vec![TOBIAH.to_owned(), LIBBY.to_owned(), "@kiko:x".to_owned()];
|
||||
let her = Member { names_from: "test", addressee: Addressee::new("@kiko:x", ["kiko"]), entry: CastEntry { id: "@kiko:x".into(), name: "Kiko".into(), state: PathBuf::new(), rooms: vec![], own_rooms: vec![] }, state: Value::Null, rooms: vec!["#a:x".into(), "#b:x".into()] };
|
||||
let cast = vec![TOBIAH.to_owned(), LIBBY.to_owned(), "@kiko:x".to_owned(), "@other:x".to_owned()];
|
||||
let line = |from: &str, room: &str| Line { from: from.into(), name: String::new(), room: room.into(), at_ms: 0, says: "hi".into(), mentions: vec![], dm_to: None, follow_up: false, reply_to: None, new: false };
|
||||
let lines = [line("@meta:x", "#a:x"), line(TOBIAH, "#a:x"), line("@kiko:x", "#b:x"), line(TOBIAH, "#b:x"), line("@meta:x", "#c:x")];
|
||||
let lines = [line("@meta:x", "#a:x"), line(TOBIAH, "#a:x"), line("@other:x", "#b:x"), line(TOBIAH, "#b:x"), line("@meta:x", "#c:x")];
|
||||
assert_eq!(mind_runs(&lines, &cast, &her), vec![0, 0, 1, 2, 3], "one run across #a and #b; a room she is not in does not break it");
|
||||
// Soul's case: Meta chatting in #eureka does not end a loop in #minds; a word from Meta in #minds does.
|
||||
let kiko = Member { rooms: vec!["#minds:x".into(), "#eureka:x".into()], ..her };
|
||||
let lines = [line(TOBIAH, "#minds:x"), line(LIBBY, "#minds:x"), line("@meta:x", "#eureka:x"), line(TOBIAH, "#minds:x"), line("@meta:x", "#minds:x"), line(LIBBY, "#minds:x")];
|
||||
assert_eq!(mind_runs(&lines, &cast, &kiko), vec![0, 1, 2, 2, 3, 0]);
|
||||
assert_eq!(LineFacts::default().mind_run, usize::MAX, "fail-safe: an uncounted run is at the cap");
|
||||
let tagged = Line { mentions: vec![LIBBY.into()], ..line(TOBIAH, "#a:x") };
|
||||
assert_eq!(wakes(WakePolicy::HumansPace(4), &her.addressee, &tagged.delivery(0, LIBBY, &[]), Speaker::Mind, LineFacts::default()), None);
|
||||
let tagged = Line { mentions: vec!["@kiko:x".into()], ..line(TOBIAH, "#a:x") };
|
||||
assert_eq!(wakes(WakePolicy::HumansPace(4), &kiko.addressee, &tagged.delivery(0, "@kiko:x", &[]), Speaker::Mind, LineFacts::default()), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -333,3 +344,23 @@ fn a_scripted_direct_message_reaches_and_wakes_only_its_recipient() {
|
|||
let harness = Harness { instance: "eureka".into(), persona: None, model: Some(&model), tuning: dir.path().join("persona-tuning.toml") };
|
||||
assert!(format!("{:#}", simulate(&harness, &path).unwrap_err()).contains("name its recipient"), "a direct message without a recipient is refused");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_turn_is_in_the_room_of_the_line_that_woke_her() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
cast(dir.path());
|
||||
let path = dir.path().join("plan.toml");
|
||||
let line = |round: usize, from: &str, room: &str, says: &str| format!("[[message]]\nround = {round}\nfrom = \"{from}\"\nname = \"X\"\nroom = \"{room}\"\nsays = \"{says}\"\n");
|
||||
// Meta speaks in Tobiah's own room, then Libby says something in #minds after it: Tobiah's turn is in his room.
|
||||
std::fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"rounds = 1\nseed = 11\nwake = {{ humans_pace = 4 }}\nbeat_s = 0\nstart = \"2026-11-20T15:00:00Z\"\nrooms = [\"#minds:gamecult.org\", \"#tobiah:gamecult.org\"]\noperators = [\"@meta:gamecult.org\"]\n[[cast]]\nid = \"{TOBIAH}\"\nname = \"Tobiah\"\nstate = \"tobiah.json\"\nown_rooms = [\"#tobiah:gamecult.org\"]\n[[cast]]\nid = \"{LIBBY}\"\nname = \"Libby\"\nstate = \"libby.json\"\n{}{}",
|
||||
line(0, "@meta:gamecult.org", "#tobiah:gamecult.org", "quiet in here"),
|
||||
line(0, LIBBY, "#minds:gamecult.org", "hello all")
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
let (_, run) = run_plan(&path, &silent());
|
||||
assert_eq!(run["turns"][0]["room"], "#tobiah:gamecult.org", "{}", run["turns"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ impl PersonaSource for Stored {
|
|||
}
|
||||
|
||||
fn request(dir: &std::path::Path, renders: Option<usize>, judge_against: Option<Value>) -> Request {
|
||||
Request { instance: INSTANCE.into(), kind: TurnKind::Chat, state: None, room: Some("#swarm:gamecult.org".into()), seed: 5, renders, judge_against, operators: operators(), minds: minds(), own_sender: OWN.into(), tuning: dir.join(TUNING_FILE), through: Through::Projector, last_heard: vec![], recent: vec![] }
|
||||
Request { instance: INSTANCE.into(), kind: TurnKind::Chat, state: None, room: Some("#swarm:gamecult.org".into()), seed: 5, renders, judge_against, operators: operators(), minds: minds(), own_sender: OWN.into(), tuning: dir.join(TUNING_FILE), through: Through::Projector, last_heard: vec![], recent: vec![], own_rooms: vec![] }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1412,3 +1412,13 @@ fn a_room_is_named_by_the_key_the_tail_carries_and_a_public_rooms_id_is_reported
|
|||
let by_id = project(&organs, &Request { room: Some("!1:gamecult.org".into()), ..request(dir.path(), None, None) }, now()).unwrap();
|
||||
assert!(by_id["room"]["why"].as_str().unwrap().contains("named by its alias"), "{}", by_id["room"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_she_knows_of_someone_is_known_privately_except_in_a_direct_message_with_them() {
|
||||
let public = Room { messages: vec![message("#minds:gamecult.org", OPERATOR, "Meta", "how is everyone?", 2, false)], here: Some("#minds:gamecult.org".into()), ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &public, &History::default(), 1);
|
||||
assert!(packet.context.contains("She knows privately: The operator rules on what the work is for."), "{}", packet.context);
|
||||
let dm = Room { messages: vec![message("!dm-meta:gamecult.org", OPERATOR, "Meta", "how are you?", 2, true)], here: Some("!dm-meta:gamecult.org".into()), direct: vec!["!dm-meta:gamecult.org".into()], ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &dm, &History::default(), 1);
|
||||
assert!(packet.context.contains("The operator rules on what the work is for.") && !packet.context.contains("knows privately: The operator"), "{}", packet.context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,11 @@ pub const TUNING_FILE: &str = "persona-tuning.toml";
|
|||
|
||||
/// The Persona stage's setting (map section 2): she continues the Projector's paragraph, her interior, with speech only
|
||||
/// where her thought moves her to it, quoted (map section 5.5, invariant 5). It is not a reply to the room.
|
||||
const PERSONA_GUIDANCE: &str = "Continue her inner stream where the paragraph leaves off: her own next thoughts, in the first person, in her own words. This is not a message to the room. If she means to say something aloud, she thinks it as she would, what and to whom; whether anything is said, and what, is decided after her. In a busy room most moments pass with nothing said.";
|
||||
const PERSONA_GUIDANCE: &str = "Continue her inner stream where the paragraph leaves off: her own next thoughts, in the first person, in her own words. This is not a message to the room. When she means to say something aloud, she writes the very words she would type, in her own voice and addressed as she would address them, never a description of what she will say. Whether she says them now is decided after her. In a busy room most moments pass with nothing said.";
|
||||
|
||||
/// The setting the Projector renders for. No task: in the Persona-only shape nothing is work she owes.
|
||||
const GUIDANCE: &str = "This person is a Mind of the GameCult swarm. She lives in its chat rooms among the operator, the other Minds and whoever drops by. Render the moment as she lives it: who is here and how they sit with her, what she carries, what she wants. What was said reaches her word for word after this stream, so never retell or summarise it: render what it stirs in her and what she makes of the people who said it. Render the conversation as it stands. Do not weigh options or list what she might do or say; what she does is hers to decide. Leave out whatever the context does not carry: an absence is not part of her moment. Use each person's pronouns as given.";
|
||||
|
||||
/// The Interpreter's speech step (map section 4, C3b): its scope and rules beside Ghostlight's membrane. It has no tools;
|
||||
/// what the membrane calls the gap tool is the `gaps` list of the JSON.
|
||||
const INTERPRETER_GUIDANCE: &str = "This step decides only what she says aloud in chat this turn, from her prose. No tool is available in this step: report every translation and every gap in the JSON object the contract describes, and return that object alone. A line is speech only when her prose shows her choosing to say it now, to the room or to someone in it. Words she recalls, quotes, or heard from someone else are never her speech, even when her prose repeats them. Thinking about saying something, deciding to stay quiet, or saying that she says nothing, is not speech. Write each line as she would type it, in her voice, without @handles or quotation marks around it, and copy into source_quote the exact words of her prose the line rests on, character for character. Name in mentions, by Matrix id from the people listed, only someone she addresses directly; in reply_to, the Matrix id of the person whose message she answers, when she answers one. The room is one of the rooms listed. An empty say list is the usual answer in a busy room.";
|
||||
|
||||
/// The context room the fixed slots need beside the identity: the hour and the mood lines always fit.
|
||||
const FIXED_ROOM: usize = 256;
|
||||
|
|
@ -177,17 +174,16 @@ impl Default for ProjectorTuning {
|
|||
}
|
||||
}
|
||||
|
||||
/// The Interpreter's speech call: its model and its guidance.
|
||||
/// The Interpreter's speech call: its model. Its prompt is code (`interpret`): what it may decide is not a knob.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct InterpreterTuning {
|
||||
pub model: String,
|
||||
pub guidance: String,
|
||||
}
|
||||
|
||||
impl Default for InterpreterTuning {
|
||||
fn default() -> Self {
|
||||
Self { model: "claude-sonnet-5-5".into(), guidance: INTERPRETER_GUIDANCE.into() }
|
||||
Self { model: "claude-sonnet-5-5".into() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +286,6 @@ impl Tuning {
|
|||
("select.group_bytes", select.group_bytes),
|
||||
("projector.guidance", self.projector.guidance.len()),
|
||||
("persona.guidance", self.persona.guidance.len()),
|
||||
("interpreter.guidance", self.interpreter.guidance.len()),
|
||||
] {
|
||||
if bytes > PART_BYTES_MAX {
|
||||
bail!("{name} must be at most {PART_BYTES_MAX} bytes, not {bytes}: the prompt must fit the connector's frame");
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ mind_body::projection: pub use select :: TurnKind ;
|
|||
mind_body::projection: pub use tuning :: { TUNING_FILE , TUNING_ROOT } ;
|
||||
mind_body::projection: struct HuginnPersonaSource pub-fields[]
|
||||
mind_body::projection: struct Organs< 'a > pub-fields[persona: Option < & 'a dyn PersonaSource >, chat: Option < & 'a dyn MouthReader >, addressing: Option < & 'a dyn HeartbeatView >, model: Option < & 'a dyn Model >]
|
||||
mind_body::projection: struct Request pub-fields[instance: String, kind: TurnKind, state: Option < Value >, room: Option < String >, seed: u64, renders: Option < usize >, judge_against: Option < Value >, operators: Vec < String >, minds: Vec < String >, own_sender: String, tuning: PathBuf, through: Through, last_heard: Vec < (String , u64) >, recent: Vec < Vec < String > >]
|
||||
mind_body::projection: struct Request pub-fields[instance: String, kind: TurnKind, state: Option < Value >, room: Option < String >, seed: u64, renders: Option < usize >, judge_against: Option < Value >, operators: Vec < String >, minds: Vec < String >, own_sender: String, tuning: PathBuf, through: Through, last_heard: Vec < (String , u64) >, recent: Vec < Vec < String > >, own_rooms: Vec < String >]
|
||||
mind_body::projection::harness: fn batch (harness : & Harness , plan_path : & Path) -> Result < String >
|
||||
mind_body::projection::harness: fn fixture_request (harness : & Harness , fixture : & Fixture , state : Option < Value > , seed : u64 , renders : Option < usize > , through : Through) -> Request
|
||||
mind_body::projection::harness: fn state_file (path : & Path , instance : & str) -> Result < Value >
|
||||
|
|
@ -281,6 +281,7 @@ mind_body::projection::select: impl Draw
|
|||
mind_body::projection::select: impl Lens
|
||||
mind_body::projection::select: impl Lines
|
||||
mind_body::projection::select: impl People < '_ >
|
||||
mind_body::projection::select: impl RoomKind
|
||||
mind_body::projection::simulate: fn simulate (harness : & Harness , plan_path : & Path) -> Result < String >
|
||||
mind_body::projection::simulate: impl HeartbeatView for Names < '_ >
|
||||
mind_body::projection::simulate: impl MouthReader for View < '_ >
|
||||
|
|
@ -295,7 +296,7 @@ mind_body::projection::tuning: impl Default for ProjectorTuning
|
|||
mind_body::projection::tuning: impl Default for SelectTuning
|
||||
mind_body::projection::tuning: impl Default for Tuning
|
||||
mind_body::projection::tuning: impl Tuning
|
||||
mind_body::projection::tuning: struct InterpreterTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String]
|
||||
mind_body::projection::tuning: struct InterpreterTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String]
|
||||
mind_body::projection::tuning: struct LensWeights # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[body_and_hour: f64, person_present: f64, unresolved_want: f64, memory_surfacing: f64, wondering: f64]
|
||||
mind_body::projection::tuning: struct Loaded # [derive (Clone , Debug , PartialEq , Serialize)] pub-fields[tuning: Tuning, source: & 'static str, sha256: String]
|
||||
mind_body::projection::tuning: struct PersonaTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String, words: usize]
|
||||
|
|
|
|||
Loading…
Reference in a new issue