From 3c2c3e48d1dd9513c57580fe951aae1a1de4cf60 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 14:51:04 +0100 Subject: [PATCH] K8: the Interpreter's guidance knob; privacy, room rules, attribution and cite-never-write stay in code (map 16.7) InterpreterTuning gains guidance, defaulting to what counts as her choosing to say it now ("A line is speech only when ...", "Wondering whether to speak ... is not speech", "An empty say list is the usual answer in a busy room"). The speech prompt splits into SPEECH_FRAME_HEAD and SPEECH_FRAME_TAIL with the guidance between them, so every frame rule after it still binds: the room and private rules, the JSON contract, whole sentences, at most two lines, the gap kinds. An empty guidance leaves no hole. Attribution: K1 strips a standalone quotation's marks, so a quoted paragraph of someone else's words would post as her own assertion. The frame now says so beside "Words she recalls or quotes from someone else are never her speech": a standalone quotation of another person's words is never her line. This is the Interpreter's reading, not a word match: who said a quotation is a language question. The default prompt is not byte-identical to K6's: one contiguous knob cannot sit where two of its sentences used to, so the guidance sentences move into one paragraph after the decision. The test holds every K6 sentence present exactly once, plus the attribution sentence. Unknown interpreter keys refuse the file; the tuning hash follows the guidance; the guidance is size-guarded. Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/interpret.rs | 25 ++++--- .../src/projection/interpret/tests.rs | 66 +++++++++++++++++-- crates/mind-body/src/projection/tests.rs | 2 +- crates/mind-body/src/projection/tuning.rs | 14 +++- crates/mind-body/tests/public_surface.txt | 2 +- 5 files changed, 91 insertions(+), 18 deletions(-) diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index ce65cf5..c3c4bb4 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -42,17 +42,22 @@ pub(crate) const MAX_LINES: usize = 2; 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. +/// The speech frame: what to say, where, to whom, and the gaps. Huginn's chat Interpreter, beside nothing of Ghostlight's +/// but its span rule. Code, not tuning (map 16.7): her words cited and never written, whole sentences, the +/// room and the private rules, attribution, the JSON contract, at most two lines and the gap kinds. The tuning's +/// `interpreter.guidance` (what counts as her choosing to say it now) is set between its second paragraph and its third, +/// so it reads as part of the decision and every rule after it still binds. +const SPEECH_FRAME_HEAD: &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, what she can do here, 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. +Below are who she is, what she can do here, 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. Words she recalls or quotes from someone else are never her speech. That holds for a quotation that stands as sentences of its own too: its marks do not go out with her line, so another person's words cited from it would reach the room as her own assertion."; -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. +/// The speech frame after the guidance. +const SPEECH_FRAME_TAIL: &str = "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\": [\"\"], \"mentions\": [\"\"], \"reply_to\": \"\"}], \"gaps\": [{\"kind\": \"conditional | addressee | elsewhere | missing_affordance\", \"quote\": \"\", \"detail\": \"\"}]} -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. A quotation that stands as sentences of its own may be cited sentence by sentence; words quoted inside a sentence of narration are cited only with that whole sentence, and then only if that sentence is what she says. 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, missing_affordance when she reaches for something her body cannot do this turn (what she can do here is listed below). 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. A quotation that stands as sentences of its own may be cited sentence by sentence; words quoted inside a sentence of narration are cited only with that whole sentence, and then only if that sentence is what she says. 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, missing_affordance when she reaches for something her body cannot do this turn (what she can do here is listed below)."; /// What a gap is (map 16.16): words she meant and did not say now, and why. Typed by code from the model's `kind`; a kind /// the contract does not name is kept as `Unresolved` and reported, never dropped. @@ -126,7 +131,7 @@ struct Proposed { reply_to: Option, } -pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str) -> String { +pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tuning: &Tuning) -> String { let mut people = String::new(); for (label, id) in &packet.people { people.push_str(&format!("- {label} \u{2014} {id}\n")); @@ -138,8 +143,12 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str) -> St if private.is_empty() { private.push_str("- none\n"); } + // The tuning's guidance, as a paragraph of its own; an empty one leaves no gap in the frame. + let guidance = tuning.interpreter.guidance.trim(); + let guidance = if guidance.is_empty() { String::new() } else { format!("{guidance}\n\n") }; format!( - "{SPEECH_PROMPT}\n\nWho she is:\n{}\n\nWhat she can do here:\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}", + "{SPEECH_FRAME_HEAD}\n\n{}{SPEECH_FRAME_TAIL}\n\nWho she is:\n{}\n\nWhat she can do here:\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}", + guidance, packet.name, capitalized(&turn_words(&packet.affordances, packet.forms)), packet.room.as_deref().unwrap_or("none"), @@ -316,7 +325,7 @@ fn echo(line: &str, bodies: &[String]) -> bool { /// 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)) { + let answer = match model.ask(request_id, &tuning.interpreter.model, &speech_prompt(packet, narration, prose, tuning)) { Ok(answer) => answer, Err(failed) => return json!({ "failed": failed.reason, "usage": failed.usage }), }; diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index 46f92de..60a937e 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -301,7 +301,7 @@ fn soul_q5d_what_she_knows_privately_about_kiko_is_listed_to_the_interpreter_in_ 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"); + let prompt = speech_prompt(&packet, "x", "y", &Tuning::default()); assert!(prompt.contains("What she knows privately, none of it to be said here:\n- private: Kiko confided she is leaving the swarm."), "{prompt}"); assert!(prompt.contains("only to the person it concerns, in a direct message with exactly that person"), "{prompt}"); // Whether a line tells it is the Interpreter's reading of its meaning: code matches no words, so a line sharing the @@ -316,7 +316,7 @@ fn in_a_direct_message_with_exactly_kiko_it_is_hers_to_say() { 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")); + assert!(speech_prompt(&packet, "x", "y", &Tuning::default()).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}"); } @@ -334,7 +334,7 @@ fn an_answer_that_is_not_the_contract_is_a_failure_not_a_silence() { 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."); + let prompt = speech_prompt(&packet, "The room is warm.", "I say nothing.", &Tuning::default()); 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", "in a direct message with exactly that person", "She never says half a sentence", "consecutive sentences", "conditional | addressee | elsewhere", "At most two lines"] { @@ -382,10 +382,66 @@ fn an_unknown_gap_kind_is_kept_as_unresolved_and_an_unlocated_quote_is_marked() #[test] fn the_interpreter_is_told_what_she_can_do_here_from_the_packets_affordances() { // Heimdall's packet: the turn line is in his pronouns. - let prompt = speech_prompt(&packet(), "x", "y"); + let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default()); assert!(prompt.contains("What she can do here:\nThis turn the room reaches him as typed lines, and he can answer in the turn's room by typing lines of his own; nothing he does here builds, changes or ships anything.\n\nThe room:"), "{prompt}"); assert!(prompt.contains("missing_affordance when she reaches for something her body cannot do this turn"), "{prompt}"); let mut listening = packet(); listening.affordances = vec![Affordance::Perceive]; - assert!(speech_prompt(&listening, "x", "y").contains("What she can do here:\nThis turn the room reaches him as typed lines; nothing"), "derived from the affordances, not a constant"); + assert!(speech_prompt(&listening, "x", "y", &Tuning::default()).contains("What she can do here:\nThis turn the room reaches him as typed lines; nothing"), "derived from the affordances, not a constant"); +} + +/// The speech prompt as K6 left it, before the guidance knob (map 16.12 K8). Every sentence of it is still in the default +/// prompt. K8 moves the guidance's sentences into one paragraph after the decision, so the default is the same sentences, +/// not the same bytes: one contiguous knob cannot sit where two of its sentences used to. +const K6_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, what she can do here, 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. 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\": [\"\"], \"mentions\": [\"\"], \"reply_to\": \"\"}], \"gaps\": [{\"kind\": \"conditional | addressee | elsewhere | missing_affordance\", \"quote\": \"\", \"detail\": \"\"}]} + +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. A quotation that stands as sentences of its own may be cited sentence by sentence; words quoted inside a sentence of narration are cited only with that whole sentence, and then only if that sentence is what she says. 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, missing_affordance when she reaches for something her body cannot do this turn (what she can do here is listed below). An empty say list is the usual answer in a busy room."; + +#[test] +fn the_default_speech_prompt_keeps_every_sentence_of_k6s_and_adds_attribution() { + let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default()); + for sentence in K6_SPEECH_PROMPT.unicode_sentences().map(str::trim).filter(|sentence| !sentence.is_empty()) { + assert_eq!(prompt.matches(sentence).count(), 1, "{sentence:?} in\n{prompt}"); + } + assert!(prompt.contains("That holds for a quotation that stands as sentences of its own too: its marks do not go out with her line, so another person's words cited from it would reach the room as her own assertion."), "{prompt}"); + assert!(prompt.starts_with("You decide what one person says aloud"), "the prefix the test doubles route on"); +} + +#[test] +fn the_guidance_knob_changes_only_the_guidance_and_the_frame_still_binds() { + let mut tuning = Tuning::default(); + tuning.interpreter.guidance = "GUIDANCE-SENTINEL: a drafted line to someone addressed counts as said.".into(); + let prompt = speech_prompt(&packet(), "x", "y", &tuning); + assert_eq!(prompt.matches("GUIDANCE-SENTINEL").count(), 1, "{prompt}"); + for gone in ["Wondering whether to speak", "An empty say list is the usual answer"] { + assert!(!prompt.contains(gone), "{gone} is guidance, and the knob replaced it"); + } + for rule in ["You never write her words: you cite them.", "never her speech", "her own assertion", "She speaks only in this room.", "in a direct message with exactly that person", "Answer with one JSON object and nothing else", "She never says half a sentence", "At most two lines.", "conditional | addressee | elsewhere | missing_affordance"] { + assert!(prompt.contains(rule), "{rule} is the frame's and no knob removes it"); + } + tuning.interpreter.guidance = " ".into(); + let bare = speech_prompt(&packet(), "x", "y", &tuning); + assert!(bare.contains("own assertion.\n\nShe speaks only in this room."), "an empty guidance leaves no hole: {bare}"); +} + +#[test] +fn an_unknown_interpreter_key_refuses_the_tuning_and_the_hash_follows_the_guidance() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("persona-tuning.toml"); + std::fs::write(&path, "[interpreter]\nfame = \"loud\"\n").unwrap(); + assert!(format!("{:#}", crate::projection::tuning::load(&path).unwrap_err()).contains("unknown field")); + std::fs::write(&path, "[interpreter]\nguidance = \"She says what she drafted to whoever addressed her.\"\n").unwrap(); + let loaded = crate::projection::tuning::load(&path).unwrap(); + assert_eq!(loaded.tuning.interpreter.guidance, "She says what she drafted to whoever addressed her."); + assert_ne!(loaded.sha256, Tuning::default().sha256(), "the tuning hash changes when the guidance does"); + let mut huge = Tuning::default(); + huge.interpreter.guidance = "g".repeat(40 * 1024); + assert!(format!("{:#}", huge.validate().unwrap_err()).contains("interpreter.guidance")); } diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 12c556f..b507d57 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -1587,7 +1587,7 @@ fn her_voice_reaches_the_projector_and_no_other_stage() { let projector = narrate::projector_prompt(&packet, &tuning); assert!(projector.contains("Who they are:\nEureka (she/her). Speaks in quartz-sentinel cadences.\n"), "{projector}"); let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning); - let speech = interpret::speech_prompt(&packet, "The room is warm.", "I say hi."); + let speech = interpret::speech_prompt(&packet, "The room is warm.", "I say hi.", &Tuning::default()); assert!(persona.contains("Who you are:\nEureka (she/her)\n"), "her name and pronouns: {persona}"); assert!(speech.contains("Who she is:\nEureka (she/her)\n"), "her name and pronouns: {speech}"); for (stage, prompt) in [("Persona", &persona), ("Interpreter", &speech)] { diff --git a/crates/mind-body/src/projection/tuning.rs b/crates/mind-body/src/projection/tuning.rs index b357813..cc1db4c 100644 --- a/crates/mind-body/src/projection/tuning.rs +++ b/crates/mind-body/src/projection/tuning.rs @@ -1,4 +1,5 @@ -//! `persona-tuning.toml`: every knob of the Select stage, the Projector and the Persona stage, read at each wake. +//! `persona-tuning.toml`: every knob of the Select stage, the Projector, the Persona stage and the Interpreter, read at +//! each wake. //! //! The file is optional. Absent, the code's defaults hold and the source reads `defaults`; present, every key it //! names overrides one default and any key the code does not know refuses the file, so a mistyped experiment fails @@ -183,16 +184,22 @@ impl Default for ProjectorTuning { } } -/// The Interpreter's speech call: its model. Its prompt is code (`interpret`): what it may decide is not a knob. +/// What counts as her choosing to say it now (map 16.7): the experiment's lever over when a drafted line is said. +const INTERPRETER_GUIDANCE: &str = "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. An empty say list is the usual answer in a busy room."; + +/// The Interpreter's speech call: its model and its guidance. The speech frame is code (`interpret`): the room and private +/// rules, attribution, citing and never writing her words, the contract and the gap kinds are not knobs. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(default, deny_unknown_fields)] pub struct InterpreterTuning { pub model: String, + /// What counts as her choosing to say it now, set inside the speech frame. + pub guidance: String, } impl Default for InterpreterTuning { fn default() -> Self { - Self { model: "claude-sonnet-5-5".into() } + Self { model: "claude-sonnet-5-5".into(), guidance: INTERPRETER_GUIDANCE.into() } } } @@ -298,6 +305,7 @@ 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"); diff --git a/crates/mind-body/tests/public_surface.txt b/crates/mind-body/tests/public_surface.txt index 333a561..3e89b22 100644 --- a/crates/mind-body/tests/public_surface.txt +++ b/crates/mind-body/tests/public_surface.txt @@ -301,7 +301,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] +mind_body::projection::tuning: struct InterpreterTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: 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]