diff --git a/crates/mind-body/fixtures/harness/golden-chorus.txt b/crates/mind-body/fixtures/harness/golden-chorus.txt index fd9f82f..4018e99 100644 --- a/crates/mind-body/fixtures/harness/golden-chorus.txt +++ b/crates/mind-body/fixtures/harness/golden-chorus.txt @@ -1,6 +1,6 @@ -responder 3: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 2 lines are the Minds' alone. -responder 4: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko answered it. Meta, who runs the place last spoke 5 min ago. The last 3 lines are the Minds' alone. -responder 5: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 4 lines are the Minds' alone. -responder 6: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 5 lines are the Minds' alone. -responder 7: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org); "nibu" (@nibu:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 6 lines are the Minds' alone. -responder 8: - the conversation: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org); "nibu" (@nibu:gamecult.org); "aqua" (@aqua:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 7 lines are the Minds… +responder 3: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 2 lines are the Minds' alone. +responder 4: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko answered it. Meta, who runs the place last spoke 5 min ago. The last 3 lines are the Minds' alone. +responder 5: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 4 lines are the Minds' alone. +responder 6: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 5 lines are the Minds' alone. +responder 7: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org); "nibu" (@nibu:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 6 lines are the Minds' alone. +responder 8: Meta, who runs the place asked the room a question, and "weksa" (@weksa:gamecult.org); "heimdall" (@heimdall:gamecult.org); Kiko; "libby" (@libby:gamecult.org); "void" (@void:gamecult.org); "nibu" (@nibu:gamecult.org); "aqua" (@aqua:gamecult.org) answered it. Meta, who runs the place last spoke 5 min ago. The last 7 lines are the Minds' alone. diff --git a/crates/mind-body/fixtures/harness/golden-group.txt b/crates/mind-body/fixtures/harness/golden-group.txt index 7a9c5b9..fd2b523 100644 --- a/crates/mind-body/fixtures/harness/golden-group.txt +++ b/crates/mind-body/fixtures/harness/golden-group.txt @@ -1,4 +1,4 @@ -quiet-beat.toml: - the conversation: Lately @libby:gamecult.org to the room; Kiko to the room. The last 3 lines are the Minds' alone. -operator-warm.toml: - the conversation: Meta, who runs the place is waiting on him. Lately Meta, who runs the place with him. Meta, who runs the place last spoke 1 min ago. -mind-teases.toml: - the conversation: Lately he to the room; @aqua:gamecult.org to the room; Kiko with him. The last 3 lines are the Minds' alone. -deru-passing.toml: - the conversation: Lately @weksa:gamecult.org to the room; Deru to the room. Deru last spoke 1 min ago. +quiet-beat.toml: - the conversation: Lately @libby:gamecult.org to the room; Kiko to the room. | The last 3 lines are the Minds' alone. +operator-warm.toml: - the conversation: Lately Meta, who runs the place with him. | Meta, who runs the place is waiting on him. Meta, who runs the place last spoke 1 min ago. +mind-teases.toml: - the conversation: Lately he to the room; @aqua:gamecult.org to the room; Kiko with him. | The last 3 lines are the Minds' alone. +deru-passing.toml: - the conversation: Lately @weksa:gamecult.org to the room; Deru to the room. | Deru last spoke 1 min ago. diff --git a/crates/mind-body/src/projection.rs b/crates/mind-body/src/projection.rs index c9307f3..6506d0d 100644 --- a/crates/mind-body/src/projection.rs +++ b/crates/mind-body/src/projection.rs @@ -294,6 +294,7 @@ fn packet_json(packet: &Packet) -> Value { "context": packet.context, "stimulus": packet.stimulus, "arrival": packet.arrival, + "speaking": packet.speaking, "heard": packet.heard, }) } diff --git a/crates/mind-body/src/projection/fixtures/golden-chat.txt b/crates/mind-body/src/projection/fixtures/golden-chat.txt index 851bacf..ceac8c1 100644 --- a/crates/mind-body/src/projection/fixtures/golden-chat.txt +++ b/crates/mind-body/src/projection/fixtures/golden-chat.txt @@ -7,8 +7,10 @@ Eureka (she/her). Dry, direct, almost feral; zeal aimed at revealing. Here and now: - now: Thursday 19 November, 14:05 UTC - mood: lighter than usual for her +- just now: Libby spoke to her here, 3 min ago +- also just now: Kiko spoke here - pronouns: Libby — she/her; Kiko — she/her -- the conversation: Lately Libby with her; Kiko to the room. The last 2 lines are the Minds' alone. +- the conversation: Lately Libby with her; Kiko to the room. Her body: - this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything. People here, as she holds them: @@ -25,15 +27,17 @@ Said to her: - Libby in #swarm:gamecult.org: "Eureka, did you see the door fix?" Also in the room: - Kiko in #swarm:gamecult.org: "She saw it. She hated it." +--- speaking +The last 2 lines are the Minds' alone. --- heard Libby, in #swarm:gamecult.org: "Eureka, did you see the door fix?" Kiko, in #swarm:gamecult.org: "She saw it. She hated it." --- projector prompt You are a private Projector. Write one person's present moment from inside it, in the first person and the present tense: the lived stream she will go on to continue in her own thought. Her interior is the point: what she feels, wants, fears and remembers, and how the people here sit with her, rendered as lived, not listed. -Render only what is established below: who she is, her present under its headings, and what reaches her. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it. What reaches her is who has said something to her, where and when, not what they said: those words are not in front of her yet and reach her only after this stream, so the stream neither quotes, guesses nor answers them. +Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it. -Render the two or three notes this moment touches and leave the rest. Do not recap the notes or what reaches her. Do not weigh options, list what she might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects. +Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what she might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects. How her words run: Dry, direct, almost feral; zeal aimed at revealing. @@ -49,8 +53,10 @@ Eureka (she/her) Here and now: - now: Thursday 19 November, 14:05 UTC - mood: lighter than usual for her +- just now: Libby spoke to her here, 3 min ago +- also just now: Kiko spoke here - pronouns: Libby — she/her; Kiko — she/her -- the conversation: Lately Libby with her; Kiko to the room. The last 2 lines are the Minds' alone. +- the conversation: Lately Libby with her; Kiko to the room. Her body: - this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything. People here, as she holds them: @@ -63,9 +69,4 @@ Notes about her, set down at another time: - need [need-relatedness], strong: She wants company that answers back. The room talks past her. - value [reveal] Reveal: Reveal, never obscure. -What reaches her: -- Libby said something to her in #swarm:gamecult.org, 3 min ago -- 1 more line in #swarm:gamecult.org, from Kiko -The words are not in front of her yet: they reach her after this moment. - Use at most 150 words. Return only the lived stream. diff --git a/crates/mind-body/src/projection/harness.rs b/crates/mind-body/src/projection/harness.rs index 311fdc3..a24f6b4 100644 --- a/crates/mind-body/src/projection/harness.rs +++ b/crates/mind-body/src/projection/harness.rs @@ -465,7 +465,8 @@ fn batch_markdown(plan_path: &Path, plan: &BatchFile, cases: &[Value]) -> String fenced(&mut out, "voice, the Projector's alone", packet["voice"].as_str().unwrap_or_default()); fenced(&mut out, "context", packet["context"].as_str().unwrap_or_default()); fenced(&mut out, "stimulus", packet["stimulus"].as_str().unwrap_or_default()); - fenced(&mut out, "arrival, the Projector's view", packet["arrival"].as_str().unwrap_or_default()); + fenced(&mut out, "arrival, the Projector's view on a turn no one spoke to her", packet["arrival"].as_str().unwrap_or_default()); + fenced(&mut out, "speaking, the Persona's and the Interpreter's", packet["speaking"].as_str().unwrap_or_default()); fenced(&mut out, "heard", packet["heard"].as_str().unwrap_or_default()); let _ = writeln!(out, "\n"); turn_markdown(&mut out, render_of(case)); diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index 6cccbbe..15a95e0 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -240,7 +240,10 @@ fn group_line_of(dir: &Path, name: &str) -> Option { let harness = harness(dir, None, None); let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None }; let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap(); - report["packet"]["context"].as_str().unwrap().lines().find(|line| line.starts_with("- the conversation")).map(str::to_owned) + let room = report["packet"]["context"].as_str().unwrap().lines().find(|line| line.starts_with("- the conversation")).map(str::to_owned); + let speaking = report["packet"]["speaking"].as_str().filter(|speaking| !speaking.is_empty()).map(str::to_owned); + // The room line the Projector reads, then the speech cues the Persona and the Interpreter read (map 16.20.2). + (room.is_some() || speaking.is_some()).then(|| format!("{} | {}", room.as_deref().unwrap_or("(none)"), speaking.as_deref().unwrap_or("(none)"))) } #[test] @@ -249,7 +252,7 @@ fn the_group_state_reads_each_scenario_room_as_the_golden_file_says() { let mut rendered = String::new(); for name in ["quiet-beat.toml", "operator-warm.toml", "mind-teases.toml", "deru-passing.toml"] { let line = group_line_of(dir.path(), name).unwrap_or_else(|| "(none)".into()); - assert!(line.len() <= 360, "the slot holds its byte budget: {line}"); + assert!(line.split(" | ").all(|part| part.len() <= 360), "each part holds its byte budget: {line}"); rendered.push_str(&format!("{name}: {line} ")); } @@ -290,8 +293,9 @@ fn the_third_to_eighth_responder_sees_a_covered_question_and_no_duty() { let organs = Organs { persona: None, chat: Some(&fixture), addressing: None, model: None }; let report = project(&organs, &fixture_request(&harness, &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap(); let context = report["packet"]["context"].as_str().unwrap().to_owned(); - let line = context.lines().find(|line| line.starts_with("- the conversation")).unwrap_or_else(|| panic!("{context}")).to_owned(); + let line = report["packet"]["speaking"].as_str().unwrap_or_default().to_owned(); assert!(line.contains("asked the room a question, and") && line.contains("answered it"), "{line}"); + assert!(!context.contains("asked the room"), "a speech cue is never the Projector's (I16.12): {context}"); for duty in ["owe", "haven't", "have not", "open", "still", "waiting on her", "to her", "unanswered"] { assert!(!line.contains(duty), "responder {}: {duty} in {line}", answered + 1); } diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 7f5aea2..e5a3d61 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -354,11 +354,13 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin if found.unfinished.is_some() { numbered.push_str(&format!("- {} began one more and was cut off before finishing it: it is no draft and cannot be said\n", her.subj)); } + // The conversation's speech cues, beside the room, where whether she speaks is decided (map 16.20.2). + let conversation = if packet.speaking.is_empty() { String::new() } else { format!("The conversation: {}\n", packet.speaking) }; // The tuning's guidance, as a paragraph of its own; an empty one leaves no gap in the frame. let guidance = voiced(tuning.interpreter.guidance.trim(), her); let guidance = if guidance.is_empty() { String::new() } else { format!("{guidance}\n\n") }; format!( - "{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\nWho is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\nWhat reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}", + "{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\nWhat reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}", speech_frame_head(her), speech_frame_tail(her), her.subj, diff --git a/crates/mind-body/src/projection/narrate.rs b/crates/mind-body/src/projection/narrate.rs index 330fb03..c67c8f5 100644 --- a/crates/mind-body/src/projection/narrate.rs +++ b/crates/mind-body/src/projection/narrate.rs @@ -145,7 +145,7 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize { /// interior its world kernel did not assert; a Mind's interior is the point of her stream. Kept from it: render only what /// the context and stimulus establish, an absence is unavailable and suspicion is uncertainty, say plainly what is /// unknown rather than filling it, no recap, never choose actions, emit schemas, expose field names or claim world -/// effects, and the word budget. Dropped: its ban on temperament, mood and inner voice, "no metaphor, no atmosphere", +/// effects, and the word budget. Nothing in it tells her what she has not yet read (map 16.20.1). Dropped: its ban on temperament, mood and inner voice, "no metaphor, no atmosphere", /// "say only what changes the decision" and "a thin moment gets a thin stream". Added: the first person and the present /// tense; what the packet's headings mean (map 16.5, I16.4); that what came of her last turn is news she is only now /// finding out, rendered as noticed and never as a list (map 16.16); that the notes are material, @@ -160,9 +160,9 @@ pub(crate) fn projector_frame(her: Forms) -> String { format!( "{PROJECTOR_OPENING} Write one person's present moment from inside it, in the first person and the present tense: the lived stream {subj} will go on to continue in {poss} own thought. {cap_poss} interior is the point: what {subj} feel{s}, want{s}, fear{s} and remember{s}, and how the people here sit with {obj}, rendered as lived, not listed. -Render only what is established below: who {subj} {be}, {poss} present under its headings, and what reaches {obj}. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it. What reaches {obj} is who has said something to {obj}, where and when, not what they said: those words are not in front of {obj} yet and reach {obj} only after this stream, so the stream neither quotes, guesses nor answers them. +Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it. -Render the two or three notes this moment touches and leave the rest. Do not recap the notes or what reaches {obj}. Do not weigh options, list what {subj} might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects." +Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what {subj} might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects." ) } @@ -170,13 +170,15 @@ Render the two or three notes this moment touches and leave the rest. Do not rec pub(crate) const PROJECTOR_OPENING: &str = "You are a private Projector."; /// The Projector's prompt, in this order: the frame, how her words run (her voice, under its own heading, map 16.19.3), -/// the tuning's guidance, the lens as where to begin, her name, the packet's headed sections, the stimulus and the word -/// budget. +/// the tuning's guidance, the lens as where to begin, her name, the packet's headed sections, what reaches her on a turn +/// no one spoke to her (none on a chat turn, map 16.20.1), and the word budget. So a chat turn's prompt ends on her +/// material, never on the person waiting. pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String { let her = packet.forms; let voice = if packet.voice.is_empty() { String::new() } else { format!("How {} words run:\n{}\n\n", her.poss, packet.voice) }; + let arrival = if packet.arrival.is_empty() { String::new() } else { format!("\n\nWhat reaches {}:\n{}", her.obj, packet.arrival) }; format!( - "{}\n\n{voice}Guidance:\n{}\n\nBegin from {}.\n\nWho {} {}:\n{}\n\n{}\n\nWhat reaches {}:\n{}\n\nUse at most {} words. Return only the lived stream.", + "{}\n\n{voice}Guidance:\n{}\n\nBegin from {}.\n\nWho {} {}:\n{}\n\n{}{arrival}\n\nUse at most {} words. Return only the lived stream.", projector_frame(her), voiced(tuning.projector.guidance.trim(), her), packet.lens.words(&packet.forms), @@ -184,8 +186,6 @@ pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String { her.be, packet.name, packet.context, - her.obj, - packet.arrival, word_budget(packet.kind, tuning), ) } @@ -231,6 +231,16 @@ pub(crate) fn lived_stream(narration: &str, heard: &str) -> String { if heard.trim().is_empty() { narration.to_owned() } else { format!("{narration}\n\n{heard}") } } +/// What the Persona reads after the stream: the conversation's speech cues first (`The room: …`, map 16.20.2), so she +/// drafts or stays silent knowing who is waiting, then what was said, verbatim. +pub(crate) fn read_after(packet: &Packet) -> String { + match (packet.speaking.is_empty(), packet.heard.trim().is_empty()) { + (true, _) => packet.heard.clone(), + (false, true) => format!("The room: {}", packet.speaking), + (false, false) => format!("The room: {}\n{}", packet.speaking, packet.heard), + } +} + /// The speech form (map 16.19.1): how she sets apart the words she would type, so that the speech boundary is hers, as /// author, and no code reads her punctuation for it. Code, not tuning: the form is an invariant, not an experiment knob. /// In her own pronouns (16.19.7). @@ -249,7 +259,7 @@ pub(crate) fn persona_prompt(packet: &Packet, narration: &str, tuning: &Tuning) let guidance = voiced(tuning.persona.guidance.trim(), packet.forms); let form = persona_speech_form(packet.forms); let domain_guidance = if guidance.is_empty() { form } else { format!("{form}\n\n{guidance}") }; - build_persona_prompt(&PersonaPrompt { identity: &packet.name, lived_stream: &lived_stream(narration, &packet.heard), domain_guidance: &domain_guidance, word_budget: tuning.persona.words }) + build_persona_prompt(&PersonaPrompt { identity: &packet.name, lived_stream: &lived_stream(narration, &read_after(packet)), domain_guidance: &domain_guidance, word_budget: tuning.persona.words }) } /// The share of the narration's word trigrams that also appear in what she heard: a lexical overlap, cheap and blind to diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index 8a2f585..118fdfb 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -7,7 +7,8 @@ //! Every packet carries its fixed slots: what came of her last turn when there is one (`outcome`, first), identity, the //! hour, her mood when it leans, her body (`body_lines`: her senses //! and actuators from `embodiment`, and what this turn can do from `Affordance`), a bond line for each person -//! present, the group state (who has been talking to whom, `group_line`), and the stimulus. The rest comes from her +//! present, who just spoke to her (`just_now`), who has been talking to whom (`conversation`; its speech cues are the +//! Persona's and the Interpreter's, never the Projector's), and the stimulus. The rest comes from her //! state's pools. The context is rendered in headed sections (`Section`), each saying what kind of text its lines are, //! and every anchored thought by one renderer (`thought_line`). Each candidate is ordered by //! `log(score) / T` plus Gumbel noise and included with probability `1 - exp(-score / inclusion_score)`, where @@ -267,9 +268,14 @@ pub(crate) struct Packet { pub sections: Sections, /// What reached her as typed lines, the words quoted: the Interpreter's and the report's, never the Projector's. pub stimulus: String, - /// What reached her as the Projector is shown it (map 16.19.2, I16.7): who said something to her, where and when, never - /// the words; on a beat, whom she last heard from. + /// What reaches her on a turn no one spoke to her, as the Projector is shown it under its own heading: on a beat, + /// that nothing addressed her and whom she last heard from; a follow-up's finding; a reflection's stock-take. Empty + /// on a chat turn, whose who, where and when is a line of Here and now (map 16.20.1). Never the words said to her + /// (I16.7). pub arrival: String, + /// The speech cues of the conversation (`conversation`, map 16.20.2): the Persona's, at the head of what she reads + /// after the stream, and the Interpreter's, beside the room. Never the Projector's (I16.12). Empty when none. + pub speaking: String, /// What was said to her, verbatim, rendered by code for the Persona stage: a chat turn's messages, a beat's recent /// room lines. pub heard: String, @@ -938,39 +944,27 @@ fn beat_heard(inputs: &Inputs, tuning: &Tuning) -> String { newest_that_fit(&lines, tuning.select.heard_bytes).0.join("\n") } -/// What reaches a chat turn's Projector (map 16.19.2, I16.7): who said something to her, where and how long ago, and how -/// many others spoke where, never what was said. The words reach her verbatim at the Persona step, after the stream, and -/// the arrival says so, so the Projector neither quotes, guesses nor answers them. -fn chat_arrival(inputs: &Inputs, tuning: &Tuning) -> String { +/// Who just spoke to her on a chat turn, as the room stands (map 16.20.1, I16.7): a line per message to her, then one per +/// room where others spoke. Who, where and when, and nothing else: never the words, and nothing about what she has or +/// has not read. "here" is the turn's room. +fn just_now(inputs: &Inputs) -> Vec { let messages: Vec<&RoomLine> = inputs.room.messages.iter().filter(|line| line.sender != inputs.people.own_sender).collect(); - if messages.is_empty() { - return "Nothing new was said.".into(); - } let her = forms(inputs.state); + let here = turn_room(inputs); + let place = |room: &str| if Some(room) == here { "here".to_owned() } else { format!("in {room}") }; let (to_her, others): (Vec<&RoomLine>, Vec<&RoomLine>) = messages.into_iter().partition(|line| line.to_her); - let mut lines: Vec = to_her.iter().map(|line| format!("- {} said something to {} in {}, {} min ago", name_of(line, inputs), her.obj, line.room, minutes(inputs.now, line.at_ms))).collect(); - let mut rooms: Vec<(&str, Vec, usize)> = Vec::new(); + let mut lines: Vec = to_her.iter().map(|line| format!("- just now: {} spoke to {} {}, {} min ago", name_of(line, inputs), her.obj, place(&line.room), minutes(inputs.now, line.at_ms))).collect(); + let mut rooms: Vec<(&str, Vec)> = Vec::new(); for line in others { let name = name_of(line, inputs); - match rooms.iter_mut().find(|(room, ..)| *room == line.room) { - Some((_, names, count)) => { - *count += 1; - if !names.contains(&name) { - names.push(name); - } - } - None => rooms.push((&line.room, vec![name], 1)), + match rooms.iter_mut().find(|(room, _)| *room == line.room) { + Some((_, names)) if !names.contains(&name) => names.push(name), + Some(_) => {} + None => rooms.push((&line.room, vec![name])), } } - lines.extend(rooms.into_iter().map(|(room, names, count)| format!("- {count} {} in {room}, from {}", if count == 1 { "more line" } else { "more lines" }, names.join("; ")))); - let note = format!("The words are not in front of {} yet: they reach {} after this moment.", her.obj, her.obj); - let (kept, dropped) = newest_that_fit(&lines, tuning.select.stimulus_bytes.saturating_sub(note.len() + 40)); - let mut out = kept; - if dropped > 0 { - out.insert(0, format!("({dropped} earlier not shown)")); - } - out.push(note); - out.join("\n") + lines.extend(rooms.into_iter().map(|(room, names)| format!("- also just now: {} spoke {}", names.join("; "), place(room)))); + lines } /// The tail lines a beat's stimulus quotes: the newest `beat_tail_lines` of others'. @@ -1149,19 +1143,26 @@ fn label_of(line: &RoomLine, inputs: &Inputs) -> String { if line.sender == inputs.people.own_sender { forms(inputs.state).subj.to_owned() } else { name_of(line, inputs) } } -/// The group-state slot (`select.group_state`): the conversation as it stands over the room's last `group_lines` lines. -/// Who has been talking with whom; a human's question to the room that others have answered, as covered (one nobody -/// answered is not mentioned); when a human last spoke; how many Mind lines in a row; and a human waiting on her by name -/// since she last spoke. Never what she owes: the room's state, not her duty. Whom a line is to is read from the names in -/// it and Matrix's word, a cue the Interpreter (C3b) will replace. None when the room shows no line. -fn group_line(inputs: &Inputs, tuning: &Tuning) -> Option { +/// The group state (`select.group_state`): the conversation as it stands over the room's last `group_lines` lines, in two +/// parts by who reads them (map 16.20.2, I16.12). `room` is who has been talking with whom ("lately X with Y"): room +/// state, the Projector's. `speaking` is the speech cues: a human waiting on her by name since she last spoke, a human's +/// question to the room that others have answered (one nobody answered is not mentioned), when a human last spoke, and how +/// many Mind lines in a row. They are for the stages that decide speech, the Persona and the Interpreter, and never the +/// Projector's, which must not steer. Never what she owes: the room's state, not her duty. Whom a line is to is read from +/// the names in it and Matrix's word. Each part is None when it says nothing. +struct Conversation { + room: Option, + speaking: Option, +} + +fn conversation(inputs: &Inputs, tuning: &Tuning) -> Conversation { let lines = recent_lines(inputs); - if lines.is_empty() { - return None; + if lines.is_empty() || !tuning.select.group_state { + return Conversation { room: None, speaking: None }; } let own = inputs.people.own_sender; let names_her = |line: &RoomLine| line.sender != own && (line.to_her || [localpart(own), text(inputs.state, &["publicName"])].iter().any(|name| crate::address::names_whole_word(&line.text, name, false))); - // Everything the line says is over these lines: its last `group_lines`. + // Everything the parts say is over these lines: the room's last `group_lines`. let window = &lines[lines.len().saturating_sub(tuning.select.group_lines)..]; let named_in = |line: &RoomLine| window.iter().filter(|other| other.sender != line.sender).find(|other| names_of(other, inputs).iter().any(|name| crate::address::names_whole_word(&line.text, name, false))).copied(); // A human's last line, when it is a question to the room (no one named), and who has answered it since. @@ -1192,31 +1193,31 @@ fn group_line(inputs: &Inputs, tuning: &Tuning) -> Option { talk.push(pair); } } - let mut parts = Vec::new(); + let mut speaking = Vec::new(); // A human waiting on her by name: a line of a human's that names or tags her, after her own last line. First, so // no clip cuts it; said only when true. let her_last = window.iter().rposition(|line| line.sender == own); if let Some(line) = window.iter().enumerate().rev().find(|(at, line)| her_last.is_none_or(|last| *at > last) && !is_mind(inputs, &line.sender) && names_her(line)).map(|(_, line)| line) { - parts.push(format!("{} is waiting on {}", label_of(line, inputs), forms(inputs.state).obj)); + speaking.push(format!("{} is waiting on {}", label_of(line, inputs), forms(inputs.state).obj)); } if let Some(asked) = question && !answered.is_empty() { - parts.push(format!("{} asked the room a question, and {} answered it", label_of(window[asked], inputs), answered.join("; "))); - } - if !talk.is_empty() { - parts.push(format!("lately {}", talk.join("; "))); + speaking.push(format!("{} asked the room a question, and {} answered it", label_of(window[asked], inputs), answered.join("; "))); } if let Some(line) = window.iter().rev().find(|line| !is_mind(inputs, &line.sender)) { - parts.push(format!("{} last spoke {} min ago", label_of(line, inputs), minutes(inputs.now, line.at_ms))); + speaking.push(format!("{} last spoke {} min ago", label_of(line, inputs), minutes(inputs.now, line.at_ms))); } let minds_in_a_row = window.iter().rev().take_while(|line| is_mind(inputs, &line.sender)).count(); if minds_in_a_row >= 2 { - parts.push(format!("the last {minds_in_a_row} lines are the Minds' alone")); + speaking.push(format!("the last {minds_in_a_row} lines are the Minds' alone")); } // Each part a sentence of its own: the lists inside a part use semicolons, and a label may hold a comma. - let sentences: Vec = parts.iter().map(|part| sentence(part)).collect(); - (!sentences.is_empty()).then(|| clip(&format!("- the conversation: {}", sentences.join(" ")), tuning.select.group_bytes)) + let sentences = |parts: &[String]| parts.iter().map(|part| sentence(part)).collect::>().join(" "); + Conversation { + room: (!talk.is_empty()).then(|| clip(&format!("- the conversation: {}", sentence(&format!("lately {}", talk.join("; ")))), tuning.select.group_bytes)), + speaking: (!speaking.is_empty()).then(|| clip(&sentences(&speaking), tuning.select.group_bytes)), + } } /// The pronouns of everyone the packet names from the room: `tuning.pronouns` by Matrix id (the persona state has no @@ -1536,10 +1537,10 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { TurnKind::FollowUp => (clip(&format!("{} just found: {}", forms(inputs.state).cap_subj, inputs.observation.unwrap_or("nothing")), tuning.select.stimulus_bytes), String::new(), Overflow::default()), TurnKind::Reflection => (reflection_stimulus(inputs, tuning), String::new(), Overflow::default()), }; - // The Projector's view of what reached her: never the words said to her (I16.7). A follow-up's finding and a - // reflection's stock-take are no one's speech, and stay. + // What reaches her on a turn no one spoke to her, as the Projector is shown it: never the words said to her (I16.7). + // A follow-up's finding and a reflection's stock-take are no one's speech, and stay. A chat turn's is room state. let arrival = match inputs.kind { - TurnKind::Chat => chat_arrival(inputs, tuning), + TurnKind::Chat => String::new(), TurnKind::Beat => beat_contacts(inputs, tuning), TurnKind::FollowUp | TurnKind::Reflection => stimulus.clone(), }; @@ -1608,7 +1609,20 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { _ => named.push(name.clone()), } } - let room_lines = [pronoun_line(inputs, tuning), group_line(inputs, tuning).filter(|_| tuning.select.group_state), also_here(&named)]; + // Who just spoke to her, first among the room lines, in at most half of what the guard has left, newest kept and the + // rest counted. + if inputs.kind == TurnKind::Chat { + let lines = just_now(inputs); + let (kept, dropped) = newest_that_fit(&lines, context.room(Section::Here) / 2); + if dropped > 0 { + context.push(Section::Here, format!("- ({dropped} earlier just now not shown)")); + } + for line in kept { + context.push(Section::Here, line); + } + } + let conversation = conversation(inputs, tuning); + let room_lines = [pronoun_line(inputs, tuning), conversation.room, also_here(&named)]; for line in room_lines.into_iter().flatten() { context.push(Section::Here, line); } @@ -1666,5 +1680,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { TurnKind::FollowUp | TurnKind::Reflection => Vec::new(), }; 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, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, arrival } + Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, arrival, speaking: conversation.speaking.unwrap_or_default() } } diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 3e74d70..d266578 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -141,13 +141,14 @@ fn whole(packet: &Packet) -> String { fn golden_chat_packet() { let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 7); let rendered = format!( - "lens: {:?}\nselected: {}\npresent: {}\n--- identity\n{}\n--- context\n{}\n--- stimulus\n{}\n--- heard\n{}\n--- projector prompt\n{}\n", + "lens: {:?}\nselected: {}\npresent: {}\n--- identity\n{}\n--- context\n{}\n--- stimulus\n{}\n--- speaking\n{}\n--- heard\n{}\n--- projector prompt\n{}\n", packet.lens, ids(&packet).join(", "), packet.present.join(", "), packet.identity(), packet.context, packet.stimulus, + packet.speaking, packet.heard, narrate::projector_prompt(&packet, &Tuning::default()), ); @@ -1680,8 +1681,11 @@ fn the_projector_frame_is_huginns_lived_frame_and_carries_no_ghostlight_membrane assert!(prompt.contains(kept), "{kept}"); } let at = |part: &str| prompt.find(part).unwrap_or_else(|| panic!("{part} in {prompt}")); - let order = ["How her words run:\n", "Guidance:\n", "Begin from ", "Who she is:\n", "Here and now:\n", "People here, as she holds them:\n", "Notes about her, set down at another time:\n", "What reaches her:\n", "Use at most "]; - assert!(order.windows(2).all(|pair| at(pair[0]) < at(pair[1])), "the frame, the voice, the guidance, the lens, the name, the sections, the stimulus, the budget: {prompt}"); + let order = ["How her words run:\n", "Guidance:\n", "Begin from ", "Who she is:\n", "Here and now:\n", "People here, as she holds them:\n", "Notes about her, set down at another time:\n", "Use at most "]; + assert!(order.windows(2).all(|pair| at(pair[0]) < at(pair[1])), "the frame, the voice, the guidance, the lens, the name, the sections, the budget: {prompt}"); + // A chat turn's prompt ends on her material: the notes, then the word budget (map 16.20.2). + let tail = &prompt[at("Notes about her, set down at another time:\n")..]; + assert!(!prompt.contains("What reaches") && tail.split("\n\n").count() == 2 && tail.split("\n\n").nth(1).is_some_and(|last| last.starts_with("Use at most")), "{prompt}"); assert!(!narrate::projector_frame(packet.forms).contains("manner"), "the heading carries what the manner sentence said"); assert!(!prompt.contains("Notes on their present"), "the sections carry their own headings: {prompt}"); } @@ -1715,7 +1719,7 @@ fn the_projector_is_told_not_to_retell_not_to_offer_options_and_not_to_owe() { for absent in ["no task is waiting", "owed", "debt"] { assert!(!prompt.contains(absent), "the guidance names no duty, even to deny one: {absent}"); } - for rule in ["neither quotes, guesses nor answers them", "Do not weigh options", "an absence is not part of her moment", "pronouns"] { + for rule in ["Do not recap", "Do not weigh options", "an absence is not part of her moment", "pronouns"] { assert!(prompt.contains(rule), "{rule}"); } let persona = narrate::persona_prompt(&packet, "The room is warm.", &Tuning::default()); @@ -1754,7 +1758,7 @@ fn every_frame_and_default_guidance_speaks_of_him_or_them_in_their_own_pronouns( assert!(parts[0].1.contains(&format!("in {theirs} own thought")) && parts[3].1.starts_with(&format!("Continue {theirs} inner stream")), "{pronouns}"); // The prompts' own headings follow the same owner. let projector = narrate::projector_prompt(&packet, &tuning); - assert!(projector.contains(&format!("\n\nWhat reaches {}:\n", her.obj)) && projector.contains(&format!("\n\nWho {} {}:\nHeimdall", her.subj, her.be)), "{projector}"); + assert!(projector.contains(&format!("\n- just now: Libby spoke to {} here, 3 min ago\n", her.obj)) && projector.contains(&format!("\n\nWho {} {}:\nHeimdall", her.subj, her.be)), "{projector}"); let speech = interpret::speech_prompt(&packet, "x", "y", &tuning); assert!(speech.contains(&format!("{} prose:\ny", select::capitalized(her.poss))), "{speech}"); } @@ -2009,11 +2013,37 @@ fn soul_k13_the_projector_sees_who_said_something_and_never_the_words() { assert!(persona.contains(SENTINEL) && speech.contains(SENTINEL), "{kind:?}: the Persona and the Interpreter read the words verbatim: {persona}"); } let packet = packet_of(TurnKind::Chat, &state(), &chat, &History::default(), 1); - assert_eq!(packet.arrival, "- Libby said something to her in #swarm:gamecult.org, 3 min ago\n- 1 more line in #swarm:gamecult.org, from Kiko\nThe words are not in front of her yet: they reach her after this moment."); - assert!(narrate::projector_frame(packet.forms).contains("those words are not in front of her yet and reach her only after this stream")); + assert!(packet.arrival.is_empty() && packet.context.contains("\n- just now: Libby spoke to her here, 3 min ago\n- also just now: Kiko spoke here\n"), "who, where and when is room state (map 16.20.1): {}", packet.context); assert!(!tuning.projector.guidance.contains("retell"), "the retelling sentence is dead: the Projector never sees the words"); } +#[test] +fn k15_the_speaking_cues_reach_the_persona_and_the_interpreter_and_never_the_projector() { + let waiting = Room { messages: vec![message("#swarm:gamecult.org", OPERATOR, "Meta", "Eureka, are you around?", 2, true), message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "hi", 1, false)], here: Some("#swarm:gamecult.org".into()), ..Room::default() }; + let minds = Room { tail: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "", "lunch?", 90, false), message("#swarm:gamecult.org", "@kiko:gamecult.org", "", "later", 80, false)], ..Room::default() }; + let tuning = Tuning::default(); + for (kind, room, cue) in [(TurnKind::Chat, &waiting, "Meta, the operator is waiting on her. Meta, the operator last spoke 2 min ago."), (TurnKind::Beat, &minds, "The last 2 lines are the Minds' alone.")] { + let packet = packet_of(kind, &state(), room, &History::default(), 1); + assert!(packet.speaking.contains(cue), "{kind:?}: {}", packet.speaking); + let projector = narrate::projector_prompt(&packet, &tuning); + for told in ["not in front of", "yet:", "waiting on", "last spoke", "Minds' alone", "asked the room"] { + assert!(!projector.contains(told), "{kind:?}: the Projector was told {told:?}: {projector}"); + } + let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning); + let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning); + assert!(persona.contains(&format!("The room is warm.\n\nThe room: {}", packet.speaking)), "{kind:?}: at the head of what she reads after the stream: {persona}"); + assert!(speech.contains(&format!("({}).\nThe conversation: {}\nWho is in it", packet.room_kind.words(), packet.speaking)), "{kind:?}: beside the room: {speech}"); + } + // The room line stays the Projector's: who has been talking with whom. + let packet = packet_of(TurnKind::Chat, &state(), &waiting, &History::default(), 1); + assert!(packet.context.contains("- the conversation: Lately Meta, the operator with her; Kiko to the room.") && packet.context.contains("- just now: Meta, the operator spoke to her here, 2 min ago\n- also just now: Kiko spoke here"), "{}", packet.context); + // With the group state off, neither part is said. + let mut off = Tuning::default(); + off.select.group_state = false; + let quiet = packet_tuned(TurnKind::Chat, &state(), &waiting, &History::default(), 1, &off); + assert!(quiet.speaking.is_empty() && !quiet.context.contains("- the conversation"), "{}", quiet.context); +} + #[test] fn the_frame_says_once_what_the_outcome_is_in_her_own_pronouns() { for (pronouns, sentence) in [("she/her", "What came of her last turn is what came of what she last meant to do, which she is only now finding out"), ("he/him", "What came of his last turn is what came of what he last meant to do, which he is only now finding out"), ("any", "which they are only now finding out: whenever something they meant did not happen, the stream begins from it, as they notice it, never as a list")] { diff --git a/crates/mind-body/src/projection/tuning.rs b/crates/mind-body/src/projection/tuning.rs index c698d19..44ae9bd 100644 --- a/crates/mind-body/src/projection/tuning.rs +++ b/crates/mind-body/src/projection/tuning.rs @@ -152,13 +152,14 @@ pub struct SelectTuning { pub people_full: usize, /// The room lines a beat shows. pub beat_tail_lines: usize, - /// The group-state slot: who has been talking to whom, how long since a human spoke, what is addressed to her or - /// open to anyone, and how long the run of Mind lines is (prior art: group state in the prompt is what lets a - /// participant judge whether to speak). + /// The group state: who has been talking to whom (the Projector's room line), and the speech cues, who is waiting + /// on her, a covered question, how long since a human spoke and how long the run of Mind lines is, for the stages + /// that decide speech (prior art: group state in the prompt is what lets a participant judge whether to speak; map + /// 16.20.2). pub group_state: bool, /// The room lines the group state reads. pub group_lines: usize, - /// The group-state slot's bytes. + /// The bytes of each part of the group state: the room line and the speech cues. pub group_bytes: usize, pub caps: PoolCaps, }