K19 fix-up: the echo check reads the earlier lines she is shown (Soul at 0cfc386)
- `Packet::bodies` on a chat turn is the new messages and the bodies of the
earlier lines from others that `heard` shows her ("Earlier in"), never her
own; `chat_stimulus` returns the ones the heard budget kept.
- Q-E (passing on someone's words) is unanswered, so option A stands: the echo
refusal applies. A line is also an echo when it carries nearly all of one line
she heard that is itself long enough to judge (ECHO_OVERLAP of that line's
trigrams in hers), so a line said verbatim behind a lead-in, or with words of
her own after it, is refused. Live, Heimdall said Meta's 40-minute-old line
verbatim with an attribution and two sentences of his own; the share of his
line's trigrams that were hers is well under 0.8 and let it through.
- What this gives up: a Mind that means to pass on a long line whole cannot,
until Q-E rules otherwise; a line under ECHO_MIN_WORDS still can be.
Verification: Meta's earlier line said bare, behind "Meta, 40 min ago:", and as
Heimdall's live draft is refused as echo; her own sentence naming the matter is
said. The K19 fixture's bodies now hold the earlier line from Meta, not her own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0cfc386f27
commit
f5d80dda26
3 changed files with 55 additions and 22 deletions
|
|
@ -11,8 +11,9 @@
|
|||
//! Interpreter's judgement, as privacy is. What this gives up: speech she does not set down is never said (an
|
||||
//! `unwritten` gap records it), and she cannot say half a draft.
|
||||
//!
|
||||
//! Code keeps a line only when it names a draft not already used; drops an echo (at least `ECHO_MIN_WORDS` words, at
|
||||
//! least `ECHO_OVERLAP` of its word trigrams in the bodies the stimulus quoted to her); keeps at most `MAX_LINES` lines;
|
||||
//! Code keeps a line only when it names a draft not already used; drops an echo (at least `ECHO_MIN_WORDS` words, and
|
||||
//! at least `ECHO_OVERLAP` of its word trigrams in the bodies of the lines she was shown, or at least that share of one
|
||||
//! such line's trigrams in it: `echo`); keeps at most `MAX_LINES` 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. Whether a draft tells what she knows privately is a reading of its meaning, so it is the
|
||||
//! Interpreter's judgement over the private items the packet lists to it (`Packet::private`), never a word match here.
|
||||
|
|
@ -387,11 +388,15 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
)
|
||||
}
|
||||
|
||||
/// Whether a line is someone else's words: long enough to judge, and nearly all a run of what she heard, by word
|
||||
/// trigrams against the bodies the stimulus quoted (`heard_overlap`). Short answers such as "ok" or "Hi" are never
|
||||
/// echoes, and a line that answers a claim by naming it is not one.
|
||||
/// Whether a line carries someone else's words (Q-E unanswered, so option A: the echo refusal applies): long enough to
|
||||
/// judge, and either nearly all a run of what she heard, or carrying nearly all of one line she heard that is itself
|
||||
/// long enough to judge, by word trigrams against the bodies of the lines she was shown (`Packet::bodies`, the earlier
|
||||
/// lines too; `heard_overlap`). The second catches a line said verbatim behind a lead-in or with words of her own after
|
||||
/// it. Short answers such as "ok" or "Hi" are never echoes, a short line she heard is never one, and a line that answers
|
||||
/// a claim by naming it is not one.
|
||||
fn echo(line: &str, bodies: &[String]) -> bool {
|
||||
line.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).count() >= ECHO_MIN_WORDS && heard_overlap(line, &bodies.join("\n")) >= ECHO_OVERLAP
|
||||
let long = |text: &str| text.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).count() >= ECHO_MIN_WORDS;
|
||||
long(line) && (heard_overlap(line, &bodies.join("\n")) >= ECHO_OVERLAP || bodies.iter().any(|body| long(body) && heard_overlap(body, line) >= ECHO_OVERLAP))
|
||||
}
|
||||
|
||||
/// One speech decision: the Interpreter's schema turn, then code's hold on each line. The report carries the lines said,
|
||||
|
|
|
|||
|
|
@ -296,8 +296,8 @@ pub(crate) struct Packet {
|
|||
/// The one room she may speak in this turn, and its kind.
|
||||
pub room: Option<String>,
|
||||
pub room_kind: RoomKind,
|
||||
/// The bodies of the lines the stimulus quoted to her this turn, without speakers or rooms: a chat turn's messages,
|
||||
/// a beat's tail lines. What an echo is measured against.
|
||||
/// The bodies of the lines she was shown this turn, without speakers or rooms: a chat turn's messages and the earlier
|
||||
/// lines from others its `heard` shows her (map 16.20.3), a beat's tail lines. What an echo is measured against.
|
||||
pub bodies: Vec<String>,
|
||||
/// The words of each private item this packet shows her as known privately: none of them may be said in this room.
|
||||
pub private: Vec<String>,
|
||||
|
|
@ -818,10 +818,11 @@ fn said_to_her<'a>(to_her: &[&'a RoomLine], render: impl Fn(&RoomLine, &str) ->
|
|||
Addressed { shown, left_out, clipped }
|
||||
}
|
||||
|
||||
fn chat_stimulus(inputs: &Inputs, tuning: &Tuning) -> (String, String, Overflow) {
|
||||
/// A chat turn's stimulus, what she heard, the overflow, and the bodies of the earlier lines from others it shows her.
|
||||
fn chat_stimulus(inputs: &Inputs, tuning: &Tuning) -> (String, String, Overflow, Vec<String>) {
|
||||
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(), String::new(), Overflow::default());
|
||||
return ("Nothing new was said.".into(), String::new(), Overflow::default(), Vec::new());
|
||||
}
|
||||
let (to_her, others): (Vec<&RoomLine>, Vec<&RoomLine>) = messages.into_iter().partition(|line| line.to_her);
|
||||
let typed = |line: &RoomLine, body: &str| format!("- {} in {}: {body}", name_of(line, inputs), line.room);
|
||||
|
|
@ -869,24 +870,28 @@ fn chat_stimulus(inputs: &Inputs, tuning: &Tuning) -> (String, String, Overflow)
|
|||
}
|
||||
// The conversation as it is on screen (map 16.20.3): the room's lines before the new ones, verbatim, newest kept in
|
||||
// what `heard_bytes` leaves, then the new ones as above. The Persona's and the Interpreter's, never the Projector's
|
||||
// (I16.7); the echo check's bodies stay the new messages.
|
||||
// (I16.7). The earlier lines from others it shows her are words she heard: the echo check reads them beside the new
|
||||
// messages (`Packet::bodies`).
|
||||
let earlier = earlier_lines(inputs);
|
||||
let mut earlier_bodies = Vec::new();
|
||||
if !earlier.is_empty() {
|
||||
let (room, just) = (turn_room(inputs).unwrap_or_default(), "Just now:");
|
||||
let heading = format!("Earlier in {room}:");
|
||||
let left = tuning.select.heard_bytes.saturating_sub(heard_text.len() + just.len() + heading.len() + 3);
|
||||
let (kept, _) = newest_that_fit(&earlier, left);
|
||||
let rendered: Vec<String> = earlier.iter().map(|(line, _)| line.clone()).collect();
|
||||
let (kept, dropped) = newest_that_fit(&rendered, left);
|
||||
if !kept.is_empty() {
|
||||
heard_text = format!("{heading}\n{}\n{just}\n{heard_text}", kept.join("\n"));
|
||||
earlier_bodies = earlier[dropped..].iter().filter(|(_, line)| line.sender != inputs.people.own_sender).map(|(_, line)| line.text.clone()).collect();
|
||||
}
|
||||
}
|
||||
let overflow = Overflow { stimulus: stimulus.len().saturating_sub(tuning.select.stimulus_bytes), heard: heard_text.len().saturating_sub(tuning.select.heard_bytes), said_to_her_not_shown: left_out, clipped_bytes: clipped };
|
||||
(stimulus, heard_text, overflow)
|
||||
(stimulus, heard_text, overflow, earlier_bodies)
|
||||
}
|
||||
|
||||
/// The turn room's lines before this turn's new messages, oldest first, as the Persona reads them: who (her own lines by
|
||||
/// her name), how long ago, and the words verbatim.
|
||||
fn earlier_lines(inputs: &Inputs) -> Vec<String> {
|
||||
/// her name), how long ago, and the words verbatim; each with the line it renders.
|
||||
fn earlier_lines<'a>(inputs: &'a Inputs) -> Vec<(String, &'a RoomLine)> {
|
||||
let messages = &inputs.room.messages;
|
||||
let Some(newest) = messages.iter().map(|line| line.at_ms).max() else {
|
||||
return Vec::new();
|
||||
|
|
@ -898,7 +903,7 @@ fn earlier_lines(inputs: &Inputs) -> Vec<String> {
|
|||
.filter(|line| !new(line) && line.at_ms <= newest)
|
||||
.map(|line| {
|
||||
let name = if line.sender == inputs.people.own_sender && !own.is_empty() { clip(&one_line(own), NAME_BYTES) } else { name_of(line, inputs) };
|
||||
format!("{name}, {} min ago: {}", minutes(inputs.now, line.at_ms), spoken(&line.text))
|
||||
(format!("{name}, {} min ago: {}", minutes(inputs.now, line.at_ms), spoken(&line.text)), line)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -1566,11 +1571,11 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
let mut draw = Draw(inputs.seed);
|
||||
let (name, voice, identity_clipped) = identity_of(inputs.state, tuning);
|
||||
let mut clipped: Vec<String> = if identity_clipped { vec!["(identity)".to_owned()] } else { Vec::new() };
|
||||
let (stimulus, heard, overflow) = match inputs.kind {
|
||||
let (stimulus, heard, overflow, earlier_bodies) = match inputs.kind {
|
||||
TurnKind::Chat => chat_stimulus(inputs, tuning),
|
||||
TurnKind::Beat => (beat_stimulus(inputs, tuning), beat_heard(inputs, tuning), Overflow::default()),
|
||||
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()),
|
||||
TurnKind::Beat => (beat_stimulus(inputs, tuning), beat_heard(inputs, tuning), Overflow::default(), Vec::new()),
|
||||
TurnKind::FollowUp => (clip(&format!("{} just found: {}", forms(inputs.state).cap_subj, inputs.observation.unwrap_or("nothing")), tuning.select.stimulus_bytes), String::new(), Overflow::default(), Vec::new()),
|
||||
TurnKind::Reflection => (reflection_stimulus(inputs, tuning), String::new(), Overflow::default(), Vec::new()),
|
||||
};
|
||||
// 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.
|
||||
|
|
@ -1586,7 +1591,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
let her = forms(inputs.state);
|
||||
let mut context = Context::new(guards(tuning, her), her);
|
||||
let bodies: Vec<String> = match inputs.kind {
|
||||
TurnKind::Chat => inputs.room.messages.iter().map(|line| line.text.clone()).collect(),
|
||||
TurnKind::Chat => inputs.room.messages.iter().map(|line| line.text.clone()).chain(earlier_bodies).collect(),
|
||||
TurnKind::Beat => beat_tail(inputs, tuning).iter().map(|line| line.text.clone()).collect(),
|
||||
TurnKind::FollowUp | TurnKind::Reflection => Vec::new(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2084,7 +2084,7 @@ fn k19_the_conversation_on_screen_reaches_the_persona_and_the_interpreter_and_ne
|
|||
let packet = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
|
||||
let escaped = serde_json::to_string(QUESTION).unwrap();
|
||||
assert_eq!(packet.heard, format!("Earlier in #swarm:gamecult.org:\nMeta, the operator, 12 min ago: {escaped}\nEureka, 11 min ago: \"In a minute.\"\nJust now:\nLibby, in #swarm:gamecult.org: \"Eureka, back yet?\""), "the new message once, under Just now");
|
||||
assert_eq!(packet.bodies, ["Eureka, back yet?"], "an echo is measured against the new messages only");
|
||||
assert_eq!(packet.bodies, ["Eureka, back yet?", QUESTION], "an echo is measured against the new messages and the earlier lines from others she is shown, never her own");
|
||||
let tuning = Tuning::default();
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning);
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning);
|
||||
|
|
@ -2094,6 +2094,29 @@ fn k19_the_conversation_on_screen_reaches_the_persona_and_the_interpreter_and_ne
|
|||
assert_eq!(packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 1).heard, "Libby, in #swarm:gamecult.org: \"Eureka, did you see the door fix?\"\nKiko, in #swarm:gamecult.org: \"She saw it. She hated it.\"");
|
||||
}
|
||||
|
||||
/// Q-E unanswered, option A: an earlier line someone else wrote, said verbatim, is an echo, bare or behind a lead-in and
|
||||
/// with words of her own after it (Heimdall's live draft at 0cfc386, Soul's K19 pass).
|
||||
#[test]
|
||||
fn an_earlier_line_she_is_shown_said_verbatim_is_refused_as_an_echo() {
|
||||
const META: &str = "Nobody touches the release branch until I'm back. I mean it, all of you.";
|
||||
let room = Room {
|
||||
messages: vec![message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "Eureka, what exactly did Meta say before she left? quote her word for word", 1, true)],
|
||||
tail: vec![message("#swarm:gamecult.org", OPERATOR, "Meta", META, 40, false)],
|
||||
here: Some("#swarm:gamecult.org".into()),
|
||||
..Room::default()
|
||||
};
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
|
||||
assert!(packet.heard.contains("40 min ago"), "the earlier line is shown to her: {}", packet.heard);
|
||||
for draft in [META.to_owned(), format!("Meta, 40 min ago: \"{META}\""), format!("Meta, 40 min ago: \"{META}\" That's the only line from her I can see. If she said anything earlier, it's not in what I have.")] {
|
||||
let decision = interpret::tests::answered(&packet, &format!("<typed>{draft}</typed>"), json!({ "say": [{ "draft": 1 }], "gaps": [] }));
|
||||
assert_eq!(decision["said"], json!([]), "{draft}");
|
||||
assert_eq!(decision["refused"][0]["reason"], "echo", "{draft}: {}", decision["refused"]);
|
||||
}
|
||||
// Her own answer that names the matter is hers.
|
||||
let decision = interpret::tests::answered(&packet, "<typed>She asked us to leave the release branch alone until she is back.</typed>", json!({ "say": [{ "draft": 1 }], "gaps": [] }));
|
||||
assert_eq!(decision["said"].as_array().map(Vec::len), Some(1), "{}", decision["refused"]);
|
||||
}
|
||||
|
||||
#[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")] {
|
||||
|
|
|
|||
Loading…
Reference in a new issue