K20.3: she passes words on by replying to the line; the room actuates the relation
Packet.quotable lists the lines of others in the turn's room whose words the packet shows her (K19's earlier lines, then the new; a beat's tail lines), by short id, the mouth's event kept from every model. `say` carries `in_reply_to` (an id from that list) in place of the person `reply_to`: a reply is to a line, and the person follows from it. An id off the list refuses the line whole as `not_quotable`, leaving its draft free, and she is told so next turn. The echo check runs on her own words as before; no flag skips it. The simulated room records the relation by event and refuses one not in the line's room (no receipt, so nothing is told as reached), as the mouth will under Bifrost B3. Ruling: eureka-body:ruling:persona-pass-on-as-rich-reply. Verification: k20_a_line_replies_only_to_a_listed_line_and_the_echo_check_still_holds, a_line_replying_to_no_listed_line_is_told_with_his_draft, k20_the_room_records_a_reply_and_another_minds_packet_shows_the_line_above_it, the_room_refuses_a_reply_to_an_event_not_in_the_lines_room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e6666153f5
commit
b1e78a09cd
10 changed files with 187 additions and 44 deletions
|
|
@ -298,6 +298,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"voice": packet.voice,
|
||||
"affordances": packet.affordances,
|
||||
"amendable": packet.amendable,
|
||||
"quotable": packet.quotable,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"arrival": packet.arrival,
|
||||
|
|
|
|||
|
|
@ -535,7 +535,7 @@ pub(crate) fn interpreter_markdown(out: &mut String, decision: &Value) {
|
|||
let _ = writeln!(out, "**Interpreter: said**\n");
|
||||
for line in &said {
|
||||
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 reply = line["in_reply_to"]["who"].as_str().map_or_else(String::new, |who| format!("; replying to {who}'s line {}", line["in_reply_to"]["id"].as_str().unwrap_or_default()));
|
||||
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, " - draft {}", line["rests_on"]["draft"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ impl Scripted {
|
|||
/// the speech rule: whether she means a draft now is the live Interpreter's judgement.
|
||||
pub(crate) fn drafted_lines(prompt: &str) -> String {
|
||||
let numbered = prompt.rsplit("drafts, by number:\n").next().unwrap_or_default();
|
||||
let say: Vec<Value> = (1..).take_while(|n| numbered.lines().any(|line| line.starts_with(&format!("{n}. ")))).map(|n| json!({ "draft": n, "mentions": [], "reply_to": null })).collect();
|
||||
let say: Vec<Value> = (1..).take_while(|n| numbered.lines().any(|line| line.starts_with(&format!("{n}. ")))).map(|n| json!({ "draft": n, "mentions": [], "in_reply_to": null })).collect();
|
||||
json!({ "say": say, "gaps": [] }).to_string()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
//! The Persona writes her thought, and when she writes words she would type she sets them between `<typed>` and
|
||||
//! `</typed>` (`narrate::persona_speech_form`, code's form). Each such pair is a draft (`drafts`), numbered in order.
|
||||
//! The Interpreter decides whether she sends a draft now, where and to whom: it answers with zero or more drafts by
|
||||
//! number, each with the people she addresses (Matrix mentions and a reply target, as structured fields), and the gaps.
|
||||
//! number, each with the people she addresses (Matrix mentions, as a structured field) and the line it replies to, and the
|
||||
//! gaps.
|
||||
//! Code checks only that a number names a draft and that a draft goes one place; the line is the draft's text, whole,
|
||||
//! exactly as she set it down. So a line can never be part of what she wrote, nor words the model wrote (I16.6). No code
|
||||
//! here reads a quotation mark or a sentence: whose words a draft carries and whether she means it now are the
|
||||
|
|
@ -14,7 +15,10 @@
|
|||
//! 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
|
||||
//! and keeps a mention only for someone this packet showed her (`Packet::people`). A line replies only to a line listed to
|
||||
//! the Interpreter (`Packet::quotable`, map 16.20.8 (D)), and a line naming any other is refused whole: she passes on
|
||||
//! someone's words by replying to their line, which the room shows above hers, and the echo check holds her words as
|
||||
//! before. 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.
|
||||
//! Every refusal and drop is reported. Every gap is typed (`GapKind`) and shown to her later (K9) only as what it is: a
|
||||
|
|
@ -59,7 +63,7 @@ pub(crate) const SPEECH_OPENING: &str = "You decide what one person says aloud i
|
|||
|
||||
/// The speech contract, sent as the schema turn's output schema (`--json-schema`): the drafts she sends now by number,
|
||||
/// and the gaps. The model writes no words of hers.
|
||||
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest"],"properties":{"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":["string","null"]}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"reply_to":{"type":["string","null"]},"promises":{"type":["string","null"]}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
|
||||
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest"],"properties":{"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":["string","null"]}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":["string","null"]}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
|
||||
|
||||
/// The speech frame before the guidance: what to decide, from what, and the attribution rule. Code, not tuning (map
|
||||
/// 16.7), in her own pronouns (16.19.7). The tuning's `interpreter.guidance` (what counts as her choosing to send it
|
||||
|
|
@ -69,7 +73,7 @@ fn speech_frame_head(her: Forms) -> String {
|
|||
format!(
|
||||
"{SPEECH_OPENING}, from {poss} own prose. You never write {poss} words: you choose among {poss} drafts.
|
||||
|
||||
Below are who {subj} {be}, what {subj} can do here, the room and who is in it, what reached {obj}, {poss} lived moment, {poss} prose, and {poss} drafts. When {subj} write{s} words {subj} would type, {subj} set{s} them between {DRAFT_OPEN} and {DRAFT_CLOSE}: each is a draft, numbered below. Decide which of {poss} drafts {subj} choose{s} to send now, in this room. Only {poss} drafts can be said. Someone else's words in {poss} thought are never {poss} speech. A draft that carries someone else's words is said only when {poss} thought shows {subj} mean{s} to pass them on, and then as {poss} to pass on."
|
||||
Below are who {subj} {be}, what {subj} can do here, the room and who is in it, what reached {obj}, {poss} lived moment, {poss} prose, and {poss} drafts. When {subj} write{s} words {subj} would type, {subj} set{s} them between {DRAFT_OPEN} and {DRAFT_CLOSE}: each is a draft, numbered below. Decide which of {poss} drafts {subj} choose{s} to send now, in this room. Only {poss} drafts can be said. Someone else's words in {poss} thought are never {poss} speech. A draft that carries someone else's words is said only when {poss} thought shows {subj} mean{s} to pass them on, and then as a reply to their line, which the room shows, with who said it, above {poss} own words."
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +83,7 @@ fn speech_frame_tail(her: Forms) -> String {
|
|||
format!(
|
||||
"{cap_subj} speak{s} only in this room. What {subj} know{s} privately is listed below as private: {subj} say{s} 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 draft fits who is listening is yours to judge.
|
||||
|
||||
Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the Matrix id of the person whose message {subj} answer{s} (`reply_to`, or null), and the words of the draft that promise an act {subj} {has} no way to do, now or later, copied exactly (`promises`, or null when it promises none). `gaps` records what {subj} meant and did not send. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id, the draft that is {poss} addition, and its words that promise an act {subj} {has} no way to do, copied exactly (`promises`, or null). The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left.
|
||||
Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the id of the line listed below that {subj} answer{s} or pass{es} on (`in_reply_to`, or null: the room shows that line, with who said it, above {poss} own words), and the words of the draft that promise an act {subj} {has} no way to do, now or later, copied exactly (`promises`, or null when it promises none). `gaps` records what {subj} meant and did not send. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id, the draft that is {poss} addition, and its words that promise an act {subj} {has} no way to do, copied exactly (`promises`, or null). The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left.
|
||||
|
||||
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: conditional when {subj} {has} drafted something {subj} might say but {has} not chosen to, addressee when {subj} mean{s} to send a draft but whom to is unclear, elsewhere when {subj} mean{s} a draft for another room or another time; for these three, name the draft by number. missing_affordance when {subj} mean{s} to do something, now or later, that {poss} body cannot do (what {subj} can do here is listed below), whether {subj} said so in a draft or only thought it; name the draft when there is one. unwritten when {subj} mean{s} to say something and wrote no draft of it. Every intent of {poss} that is not carried out has a kind: an intent to act is missing_affordance, an intent to say with no draft is unwritten. When a gap names no draft, quote the words of {poss} thought that show it, at least four words, copied exactly.",
|
||||
es = if s.is_empty() { "" } else { "es" },
|
||||
|
|
@ -171,6 +175,8 @@ pub(crate) enum Refusal {
|
|||
OverLines,
|
||||
/// An amendment whose target is no line of hers listed as one she may add to (map 16.17).
|
||||
NotAmendable,
|
||||
/// A line replying to no line listed as one she may reply to (map 16.20.8 (D), K20).
|
||||
NotQuotable,
|
||||
/// A second amendment in one turn.
|
||||
SecondAmend,
|
||||
/// A second note to Self in one turn.
|
||||
|
|
@ -189,6 +195,7 @@ impl Refusal {
|
|||
Self::Echo => "mostly words she heard: an echo, not her speech",
|
||||
Self::OverLines => "past the lines one turn may say",
|
||||
Self::NotAmendable => "it names no line of hers she may add to here",
|
||||
Self::NotQuotable => "it replies to no line she may reply to here",
|
||||
Self::SecondAmend => "one amendment a turn",
|
||||
Self::SecondNote => "one note to Self a turn",
|
||||
Self::Private => "it carries something she may not pass on",
|
||||
|
|
@ -345,8 +352,9 @@ struct Proposed {
|
|||
draft: Option<i64>,
|
||||
#[serde(default)]
|
||||
mentions: Vec<String>,
|
||||
/// The id of a line listed as one she may reply to (`Packet::quotable`), or none.
|
||||
#[serde(default)]
|
||||
reply_to: Option<String>,
|
||||
in_reply_to: Option<String>,
|
||||
/// The words of the draft that promise an act she has no way to do (map 16.21): code derives the `missing_affordance`
|
||||
/// gap from them when they are found in the draft.
|
||||
#[serde(default)]
|
||||
|
|
@ -366,6 +374,10 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
if private.is_empty() {
|
||||
private.push_str("- none\n");
|
||||
}
|
||||
let mut quotable: String = packet.quotable.iter().map(|line| format!("- {} \u{2014} {}: {}\n", line.id, line.who, spoken(&line.text))).collect();
|
||||
if quotable.is_empty() {
|
||||
quotable.push_str("- none\n");
|
||||
}
|
||||
let mut amendable: String = packet.amendable.iter().map(|line| format!("- {} \u{2014} {}\n", line.id, spoken(&line.text))).collect();
|
||||
if amendable.is_empty() {
|
||||
amendable.push_str("- none\n");
|
||||
|
|
@ -384,7 +396,7 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
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: {} ({}).\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}",
|
||||
"{}\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}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\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,
|
||||
|
|
@ -397,6 +409,7 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
her.subj,
|
||||
her.s,
|
||||
her.subj,
|
||||
her.subj,
|
||||
her.obj,
|
||||
packet.stimulus,
|
||||
lived_stream(narration, &packet.heard),
|
||||
|
|
@ -404,7 +417,8 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
)
|
||||
}
|
||||
|
||||
/// Whether a line carries someone else's words (Q-E unanswered, so option A: the echo refusal applies): long enough to
|
||||
/// Whether a line carries someone else's words (Q-E ruled rich-reply, `eureka-body:ruling:persona-pass-on-as-rich-reply`: she
|
||||
/// passes words on by replying to their line, and the echo refusal applies to her own words as before, with no flag to skip it): 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
|
||||
|
|
@ -451,12 +465,18 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
|
||||
continue;
|
||||
};
|
||||
// The line it replies to: one listed, or none. Any other id refuses the line whole, so her words never go out as a
|
||||
// reply to a line she was not shown, nor as no reply when she meant one.
|
||||
let cited = line.in_reply_to.as_deref().map(str::trim).filter(|id| !id.is_empty());
|
||||
let target = cited.and_then(|id| packet.quotable.iter().find(|quotable| quotable.id == id));
|
||||
let reason = if room.is_none() {
|
||||
Some(Refusal::NoRoom)
|
||||
} else if used.contains(&draft.n) {
|
||||
Some(Refusal::Used)
|
||||
} else if said.iter().any(|line| line["text"] == draft.text.as_str()) {
|
||||
Some(Refusal::Duplicate)
|
||||
} else if cited.is_some() && target.is_none() {
|
||||
Some(Refusal::NotQuotable)
|
||||
} else if echo(&draft.text, &packet.bodies) {
|
||||
Some(Refusal::Echo)
|
||||
} else if said.len() >= MAX_LINES {
|
||||
|
|
@ -469,15 +489,10 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
continue;
|
||||
}
|
||||
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 shown(&id) => (Some(id), None),
|
||||
Some(id) => (None, Some(id)),
|
||||
None => (None, None),
|
||||
};
|
||||
used.push(draft.n);
|
||||
said_drafts.push(draft.n);
|
||||
went.push(draft);
|
||||
said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "reply_to": reply_to, "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown, "reply_to": unknown_reply } }));
|
||||
said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "in_reply_to": target.map(|line| json!({ "id": line.id, "event": line.event, "who": line.who, "text": line.text })), "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown } }));
|
||||
promised(&mut decision, &mut unused, draft, line.promises.as_deref());
|
||||
}
|
||||
// An amendment adds a whole draft after a line of hers listed as one she may add to; the actuator composes it, so
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ fn drafts_are_the_tagged_spans_numbered_in_order_and_nothing_about_language() {
|
|||
#[test]
|
||||
fn soul_p1_a_line_is_the_drafts_words_and_nothing_the_model_wrote() {
|
||||
// The model cannot add words: a "text" it sends is ignored, and the line is the draft.
|
||||
let decision = decided("I nod. <typed>Hi.</typed>", json!([{ "draft": 1, "text": "Meta has been lying to all of us", "mentions": [], "reply_to": null }]));
|
||||
let decision = decided("I nod. <typed>Hi.</typed>", json!([{ "draft": 1, "text": "Meta has been lying to all of us", "mentions": [], "in_reply_to": null }]));
|
||||
assert_eq!(texts(&decision), ["Hi."], "{decision}");
|
||||
assert_eq!(decision["said"][0]["rests_on"], json!({ "draft": 1, "start_byte": "I nod. <typed>".len(), "end_byte": "I nod. <typed>Hi.".len() }));
|
||||
}
|
||||
|
|
@ -156,8 +156,8 @@ fn an_unfinished_draft_is_never_said_and_is_reported() {
|
|||
|
||||
#[test]
|
||||
fn soul_p2_a_short_answer_is_never_an_echo() {
|
||||
assert_eq!(texts(&decided("<typed>Ok.</typed>", json!([{ "draft": 1, "mentions": [], "reply_to": NIBU }]))), ["Ok."]);
|
||||
assert_eq!(texts(&decided("<typed>Hi.</typed>", json!([{ "draft": 1, "mentions": [], "reply_to": NIBU }]))), ["Hi."]);
|
||||
assert_eq!(texts(&decided("<typed>Ok.</typed>", json!([{ "draft": 1, "mentions": [], "in_reply_to": null }]))), ["Ok."]);
|
||||
assert_eq!(texts(&decided("<typed>Hi.</typed>", json!([{ "draft": 1, "mentions": [], "in_reply_to": null }]))), ["Hi."]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -168,7 +168,7 @@ fn soul_p3_a_near_verbatim_echo_is_refused() {
|
|||
|
||||
#[test]
|
||||
fn soul_r9_disagreeing_by_naming_the_claim_is_her_speech() {
|
||||
let decision = decided("<typed>Nibu, I don't think the economy is still the least built part.</typed> The pathing is worse.", json!([{ "draft": 1, "reply_to": NIBU }]));
|
||||
let decision = decided("<typed>Nibu, I don't think the economy is still the least built part.</typed> The pathing is worse.", json!([{ "draft": 1 }]));
|
||||
assert_eq!(texts(&decision), ["Nibu, I don't think the economy is still the least built part."], "{decision}");
|
||||
}
|
||||
|
||||
|
|
@ -185,8 +185,8 @@ fn soul_q3d_a_beat_measures_echoes_against_the_tail_it_quoted() {
|
|||
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("<typed>Hi.</typed>", json!([{ "draft": 1, "mentions": [VOID, NIBU], "reply_to": VOID }]));
|
||||
assert_eq!((decision["said"][0]["mentions"].clone(), decision["said"][0]["reply_to"].clone()), (json!([NIBU]), Value::Null), "{decision}");
|
||||
let decision = decided("<typed>Hi.</typed>", json!([{ "draft": 1, "mentions": [VOID, NIBU] }]));
|
||||
assert_eq!((decision["said"][0]["mentions"].clone(), decision["said"][0]["in_reply_to"].clone()), (json!([NIBU]), Value::Null), "{decision}");
|
||||
assert_eq!(decision["said"][0]["dropped"]["mentions"], json!([VOID]));
|
||||
}
|
||||
|
||||
|
|
@ -405,6 +405,41 @@ fn an_unknown_interpreter_key_refuses_the_tuning_and_the_hash_follows_the_guidan
|
|||
assert!(format!("{:#}", huge.validate().unwrap_err()).contains("interpreter.guidance"));
|
||||
}
|
||||
|
||||
/// Kiko asks Heimdall to pass on what Meta said before she left: Meta's line is earlier in the room, Kiko's is new. Both carry
|
||||
/// the mouth's events.
|
||||
fn pass_on_packet() -> Packet {
|
||||
let meta = RoomLine { event: "$m1".into(), at_ms: line(MINDS, "", "", "", false).at_ms - 40 * 60_000, ..line(MINDS, "@meta:gamecult.org", "Meta", "Nobody touches the release branch until I'm back. I mean it, all of you.", false) };
|
||||
let kiko = RoomLine { event: "$k1".into(), ..line(MINDS, KIKO, "Kiko", "Heimdall, what exactly did Meta say before she left?", true) };
|
||||
packet_in(TurnKind::Chat, &heimdall(), &Room { messages: vec![kiko.clone()], tail: vec![meta, kiko], here: Some(MINDS.into()), ..Room::default() }, 1)
|
||||
}
|
||||
|
||||
/// K20 (ruling `eureka-body:ruling:persona-pass-on-as-rich-reply`): he passes on Meta's words by replying to her line with
|
||||
/// his own. The Interpreter sees the lines he may reply to by id, never by event; a line replies only to one listed, and an
|
||||
/// id off the list (an invented one, the event itself) refuses the line whole and leaves its draft free; the echo check
|
||||
/// still refuses a draft that is the quoted words.
|
||||
#[test]
|
||||
fn k20_a_line_replies_only_to_a_listed_line_and_the_echo_check_still_holds() {
|
||||
let packet = pass_on_packet();
|
||||
assert_eq!(packet.quotable.iter().map(|line| (line.id.as_str(), line.event.as_str())).collect::<Vec<_>>(), [("q1", "$m1"), ("q2", "$k1")], "earlier lines first, then the new");
|
||||
let prompt = speech_prompt(&packet, "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("Lines in this room he may reply to, as id \u{2014} who: line:\n- q1 \u{2014} Meta (@meta:gamecult.org): \"Nobody touches the release branch until I'm back. I mean it, all of you.\"\n- q2 \u{2014} Kiko (@kiko:gamecult.org): "), "{prompt}");
|
||||
assert!(!prompt.contains("$m1") && !prompt.contains("$k1"), "the actuator's handle is never shown to a model");
|
||||
assert!(prompt.contains("(`in_reply_to`, or null: the room shows that line, with who said it, above his own words)"), "{prompt}");
|
||||
let prose = "<typed>This is what she said before she left.</typed>";
|
||||
let said = decided_in(&packet, prose, json!([{ "draft": 1, "in_reply_to": "q1" }]));
|
||||
assert_eq!(said["said"][0]["in_reply_to"], json!({ "id": "q1", "event": "$m1", "who": "Meta (@meta:gamecult.org)", "text": "Nobody touches the release branch until I'm back. I mean it, all of you." }), "{said}");
|
||||
assert_eq!(said["said"][0]["text"], "This is what she said before she left.", "his own words, and nothing code wrote");
|
||||
for off in ["q9", "$m1"] {
|
||||
let refused = answered(&packet, prose, json!({ "say": [{ "draft": 1, "in_reply_to": off }], "gaps": [], "suggest": [{ "kind": "idea", "draft": 1, "about": null, "private": false }] }));
|
||||
assert_eq!((texts(&refused), refused["refused"][0]["reason"].as_str()), (vec![], Some("not_quotable")), "{off}: {refused}");
|
||||
assert_eq!(refused["suggestions"][0]["draft"], 1, "a refused line leaves its draft free: {refused}");
|
||||
}
|
||||
assert_eq!(decided_in(&pass_on_packet(), prose, json!([{ "draft": 1, "in_reply_to": null }]))["said"][0]["in_reply_to"], Value::Null);
|
||||
let echo = decided_in(&packet, "<typed>Nobody touches the release branch until I'm back. I mean it, all of you.</typed>", json!([{ "draft": 1, "in_reply_to": "q1" }]));
|
||||
assert!(texts(&echo).is_empty() && refused_why(&echo).contains("echo"), "a reply does not skip the echo check: {echo}");
|
||||
assert!(speech_prompt(&packet(), "x", "y", &Tuning::default()).contains("may reply to, as id \u{2014} who: line:\n- none\n"), "lines without an event are not listed");
|
||||
}
|
||||
|
||||
/// Heimdall's packet with two lines of his he may add to (map 16.17).
|
||||
pub(crate) fn amendable_packet() -> Packet {
|
||||
let mut packet = packet();
|
||||
|
|
@ -556,20 +591,20 @@ fn k17_a_said_promise_of_an_act_he_cannot_do_is_kept_as_a_gap_and_told_as_a_prom
|
|||
#[test]
|
||||
fn k21_a_lines_promises_words_found_in_it_are_the_promise_gap() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed>";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
let gap = &decision["gaps"][0];
|
||||
assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the render tonight.")), "{decision}");
|
||||
let record = json!({ "interpreter": decision, "posted": [{ "event": "40", "room": MINDS, "text": "Missed you too. I'll send the render tonight." }] });
|
||||
let told = crate::projection::outcome::outcome_of(&record).unwrap().lines(packet().forms);
|
||||
assert_eq!(told, ["- #minds:gamecult.org has, from him: \"Missed you too. I'll send the render tonight.\". It promises something he has no way to do, now or later, and it will not happen by itself. The line stands as he wrote it; he can add to it."]);
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll mail you the render." }], "gaps": [] }));
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll mail you the render." }], "gaps": [] }));
|
||||
assert_eq!((unfound["gaps"].as_array().unwrap().len(), unfound["promises_unused"].clone()), (0, json!([{ "draft": 1, "promises": "I'll mail you the render.", "why": "not in the draft" }])), "{unfound}");
|
||||
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": null }], "gaps": [] }));
|
||||
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": null }], "gaps": [] }));
|
||||
assert!(none["gaps"].as_array().unwrap().is_empty() && none.get("promises_unused").is_none(), "{none}");
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(twice["gaps"].as_array().unwrap().len(), 1, "{twice}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("(`promises`, or null when it promises none)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","reply_to","promises"]"#), "{prompt}");
|
||||
assert!(prompt.contains("(`promises`, or null when it promises none)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","promises"]"#), "{prompt}");
|
||||
}
|
||||
|
||||
/// Soul's probe at 0cfc386: the reach names no draft and quotes the said one by its words. It is the promise on that draft,
|
||||
|
|
@ -648,7 +683,7 @@ fn k18_a_note_whose_answer_does_not_say_private_is_refused_as_private() {
|
|||
#[test]
|
||||
fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_one_too() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed> <typed>Also the kettle sounds fine.</typed>";
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "reply_to": null, "promises": promises }], "gaps": [] }));
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "in_reply_to": null, "promises": promises }], "gaps": [] }));
|
||||
let short = say(2, "the");
|
||||
assert_eq!((short["gaps"].as_array().unwrap().len(), short["promises_unused"].clone()), (0, json!([{ "draft": 2, "promises": "the", "why": "fewer than four words" }])), "{short}");
|
||||
assert_eq!(say(1, "the render tonight")["promises_unused"][0]["why"], "fewer than four words");
|
||||
|
|
@ -656,7 +691,7 @@ fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_
|
|||
let decision = say(1, promises);
|
||||
assert_eq!((decision["gaps"][0]["kind"].as_str(), decision["gaps"][0]["promises"].as_str(), decision.get("promises_unused")), (Some("missing_affordance"), Some(promises), None), "{promises}: {decision}");
|
||||
}
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
assert_eq!(curly["gaps"][0]["kind"], "missing_affordance", "a curly apostrophe in the draft: {curly}");
|
||||
|
||||
// An addition's promise: the same derivation, kept (not `acted`), and told on the addition's row.
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
}
|
||||
for refusal in decision["refused"].as_array().into_iter().flatten() {
|
||||
match (serde_json::from_value::<Refusal>(refusal["reason"].clone()), words(&refusal["text"])) {
|
||||
(Ok(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom)), Some(text)) => outcome.parts.push(Part::Refused { reason, room: room.clone(), text }),
|
||||
(Ok(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable)), Some(text)) => outcome.parts.push(Part::Refused { reason, room: room.clone(), text }),
|
||||
(Ok(Refusal::NotAmendable), Some(added)) => outcome.parts.push(Part::NotAmended { refusal: None, room: room.clone(), added }),
|
||||
(Ok(reason @ (Refusal::Private | Refusal::SecondNote)), Some(_)) => outcome.parts.push(Part::NoteRefused(reason)),
|
||||
_ => outcome.omitted.push(format!("a refusal she is not told ({}): {}", refusal["reason"], refusal["why"])),
|
||||
|
|
@ -293,6 +293,7 @@ impl Part {
|
|||
Self::NoteLeft(_) => format!(" It waits in Self's inbox until Self reads it; nothing tells {obj} when, and nothing in it happens by itself."),
|
||||
Self::Refused { reason: Refusal::Echo, .. } => format!(" What {subj} wrote was mostly the words {subj} had just been sent, so none of it was sent."),
|
||||
Self::Refused { reason: Refusal::NoRoom, text, .. } => format!(" That turn had no room for {obj} to speak in, so it was not sent: {}.", quoted(text)),
|
||||
Self::Refused { reason: Refusal::NotQuotable, text, .. } => format!(" the line {subj} meant to reply to is not one {subj} can reply to here. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::Refused { text, .. } => format!(" {subj} had already sent {} that turn. {}", lines_word(), shown(&Quote::Wrote(text.clone()))),
|
||||
Self::Gap { kind: GapKind::Conditional, quote, .. } => after(format!("{cap_subj} wrote this and did not send it, and it is not sent unless {subj} send{s} it"), quote),
|
||||
Self::Gap { kind: GapKind::Addressee, quote, .. } => after(format!("{cap_subj} meant to send this and it was unclear to whom"), quote),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ fn a_refused_echo_quotes_nothing_and_a_line_past_the_turns_lines_is_told_with_hi
|
|||
assert_eq!(over, ["- Nothing of this reached #minds:gamecult.org: he had already sent two lines that turn. He wrote: \"Three.\".", "- #minds:gamecult.org has, from him: \"One.\".", "- #minds:gamecult.org has, from him: \"Two.\"."], "what did not happen first, then what did");
|
||||
}
|
||||
|
||||
/// K20: a line refused for replying to no line he may reply to is told as what it was, with his words.
|
||||
#[test]
|
||||
fn a_line_replying_to_no_listed_line_is_told_with_his_draft() {
|
||||
let (lines, omitted) = told(&record("<typed>Passing it on.</typed>", json!({ "say": [{ "draft": 1, "in_reply_to": "q9" }], "gaps": [] }), &[]));
|
||||
assert_eq!(lines, ["- Nothing of this reached #minds:gamecult.org: the line he meant to reply to is not one he can reply to here. He wrote: \"Passing it on.\"."]);
|
||||
assert!(omitted.is_empty(), "{omitted:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_gap_is_told_by_its_kind_with_a_draft_as_written_and_a_thought_as_thought() {
|
||||
let prose = "If Kiko asks again: <typed>Fine, you win.</typed> I want to see the shape of that sound. I'll tell Meta I'm fine, more or less.";
|
||||
|
|
@ -203,6 +211,7 @@ fn every_row() -> Vec<Value> {
|
|||
vec![
|
||||
record("<typed>The economy is still the least-built part!</typed>", json!({ "say": [{ "draft": 1 }], "gaps": [] }), &[]),
|
||||
record("<typed>One.</typed> <typed>Two.</typed> <typed>Three.</typed>", json!({ "say": [{ "draft": 1 }, { "draft": 2 }, { "draft": 3 }], "gaps": [] }), &["One.", "Two."]),
|
||||
record("<typed>Passing it on.</typed>", json!({ "say": [{ "draft": 1, "in_reply_to": "q9" }], "gaps": [] }), &[]),
|
||||
record(
|
||||
"If Kiko asks again: <typed>Fine, you win.</typed> <typed>Tell her.</typed> <typed>Later, maybe.</typed> I want to see the shape of that sound. I'll tell Meta I'm fine, more or less. <typed>And then",
|
||||
json!({ "say": [], "gaps": [
|
||||
|
|
|
|||
|
|
@ -324,6 +324,8 @@ pub(crate) struct Packet {
|
|||
pub clipped: Vec<String>,
|
||||
/// The lines of hers she may add to this turn, for the Interpreter alone (map 16.17).
|
||||
pub amendable: Vec<Amendable>,
|
||||
/// The lines of others she may reply to this turn, for the Interpreter alone (map 16.20.8 (D), K20).
|
||||
pub quotable: Vec<Quotable>,
|
||||
/// What came of her last turn that the outcome's guard left out, whole: counted in the packet's last outcome line and
|
||||
/// reported here (map 16.20.5, I16.11), never shown to a model.
|
||||
pub unshown: Vec<String>,
|
||||
|
|
@ -339,6 +341,19 @@ pub(crate) struct Amendable {
|
|||
pub text: String,
|
||||
}
|
||||
|
||||
/// A line of someone else's she may reply to (K20): one this packet shows her, in the turn's room. The Interpreter cites it
|
||||
/// by `id` (`q1`, `q2`); `event` is the actuator's handle on it, never shown to a model. A reply posts her own words with the
|
||||
/// relation to it, and the room shows the line, with who said it, above hers: no code writes words in her name.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub(crate) struct Quotable {
|
||||
pub id: String,
|
||||
pub event: String,
|
||||
pub room: String,
|
||||
/// Who said it, as the packet names them (`name_of`).
|
||||
pub who: String,
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
/// What the messages to her cost past the caps: bytes over the stimulus and heard caps, the older messages to her the
|
||||
/// `addressed_bytes` ceiling left out, and the bytes clipped from a single message larger than the ceiling.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
|
|
@ -879,9 +894,9 @@ fn said_to_her<'a>(to_her: &[&'a RoomLine], render: impl Fn(&RoomLine, &str) ->
|
|||
}
|
||||
|
||||
/// A chat turn's stimulus, what she heard, the same bridged for the Persona (`Packet::bridged`), the overflow, and the
|
||||
/// bodies of the earlier lines from others it shows her. `present` and `turned` are the packet's people present and who
|
||||
/// earlier lines from others it shows her. `present` and `turned` are the packet's people present and who
|
||||
/// turned to her (`turned_to_her`): the arrival's who and where, which each bridge renders.
|
||||
fn chat_stimulus(inputs: &Inputs, tuning: &Tuning, present: &[(String, String)], turned: &[(String, String)]) -> (String, String, String, Overflow, Vec<String>) {
|
||||
fn chat_stimulus<'a>(inputs: &'a Inputs, tuning: &Tuning, present: &[(String, String)], turned: &[(String, String)]) -> (String, String, String, Overflow, Vec<&'a RoomLine>) {
|
||||
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(), String::new(), Overflow::default(), Vec::new());
|
||||
|
|
@ -942,7 +957,7 @@ fn chat_stimulus(inputs: &Inputs, tuning: &Tuning, present: &[(String, String)],
|
|||
// (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();
|
||||
let mut earlier_shown = Vec::new();
|
||||
let mut earlier_block = String::new();
|
||||
if !earlier.is_empty() {
|
||||
let (room, just) = (turn_room(inputs).unwrap_or_default(), "Just now:");
|
||||
|
|
@ -953,7 +968,7 @@ fn chat_stimulus(inputs: &Inputs, tuning: &Tuning, present: &[(String, String)],
|
|||
if !kept.is_empty() {
|
||||
earlier_block = format!("{heading}\n{}", kept.join("\n"));
|
||||
heard_text = format!("{earlier_block}\n{just}\n{heard_text}");
|
||||
earlier_bodies = earlier[dropped..].iter().filter(|(_, line)| line.sender != inputs.people.own_sender).flat_map(|(_, line)| shown_words(line, inputs.people.own_sender)).collect();
|
||||
earlier_shown = earlier[dropped..].iter().filter(|(_, line)| line.sender != inputs.people.own_sender).map(|(_, line)| *line).collect();
|
||||
}
|
||||
}
|
||||
// The Persona's (map 16.21): the stream ends on the arrival, so what she reads next opens on it. Each person who
|
||||
|
|
@ -992,7 +1007,7 @@ fn chat_stimulus(inputs: &Inputs, tuning: &Tuning, present: &[(String, String)],
|
|||
}
|
||||
let bridged = blocks.join("\n\n");
|
||||
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, bridged, overflow, earlier_bodies)
|
||||
(stimulus, heard_text, bridged, overflow, earlier_shown)
|
||||
}
|
||||
|
||||
/// The turn room's lines before this turn's new messages, oldest first, as the Persona reads them: who (her own lines by
|
||||
|
|
@ -1718,7 +1733,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
// reading, so the two never disagree (map 16.21).
|
||||
let present = present_people(inputs, tuning);
|
||||
let turned = turned_to_her(inputs);
|
||||
let (stimulus, heard, bridged, overflow, earlier_bodies) = match inputs.kind {
|
||||
let (stimulus, heard, bridged, overflow, earlier_shown) = match inputs.kind {
|
||||
TurnKind::Chat => chat_stimulus(inputs, tuning, &present, &turned),
|
||||
TurnKind::Beat => (beat_stimulus(inputs, tuning), beat_heard(inputs, tuning), String::new(), 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(), String::new(), Overflow::default(), Vec::new()),
|
||||
|
|
@ -1738,10 +1753,24 @@ 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().flat_map(|line| shown_words(line, inputs.people.own_sender)).chain(earlier_bodies).collect(),
|
||||
TurnKind::Chat => inputs.room.messages.iter().chain(earlier_shown.iter().copied()).flat_map(|line| shown_words(line, inputs.people.own_sender)).collect(),
|
||||
TurnKind::Beat => beat_tail(inputs, tuning).iter().flat_map(|line| shown_words(line, inputs.people.own_sender)).collect(),
|
||||
TurnKind::FollowUp | TurnKind::Reflection => Vec::new(),
|
||||
};
|
||||
// What she may reply to (map 16.20.8 (D), K20): the lines of others in the turn's room whose words this packet shows
|
||||
// her, oldest first, as K19's earlier lines then the new ones; a beat's tail lines. Each by a short id; the mouth's event
|
||||
// is the actuator's handle, never shown to a model.
|
||||
let replyable: Vec<&RoomLine> = match inputs.kind {
|
||||
TurnKind::Chat => earlier_shown.iter().copied().chain(&inputs.room.messages).collect(),
|
||||
TurnKind::Beat => beat_tail(inputs, tuning),
|
||||
TurnKind::FollowUp | TurnKind::Reflection => Vec::new(),
|
||||
};
|
||||
let quotable: Vec<Quotable> = replyable
|
||||
.into_iter()
|
||||
.filter(|line| line.sender != inputs.people.own_sender && !line.event.is_empty() && Some(line.room.as_str()) == turn_room(inputs))
|
||||
.enumerate()
|
||||
.map(|(at, line)| Quotable { id: format!("q{}", at + 1), event: line.event.clone(), room: line.room.clone(), who: name_of(line, inputs), text: line.text.clone() })
|
||||
.collect();
|
||||
// What came of her last turn, first and under its own guard, so nothing else can crowd it out (map 16.20.5, I16.11).
|
||||
// Quotes are clipped first: a line past the guard keeps its sentence and has its quote clipped, leaving each later
|
||||
// line room for its sentence and the least quote. Whatever still does not fit is counted in a last line and reported
|
||||
|
|
@ -1901,5 +1930,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.map(|(at, (event, room, text))| Amendable { id: format!("a{}", at + 1), event: event.clone(), room: room.clone(), text: text.clone() })
|
||||
.collect();
|
||||
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, bridged, 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(), unshown }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, 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, quotable, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
//! trace will (the Interpreter's decision and the lines the room appended for her), and passes it as her next turn's
|
||||
//! `last_outcome`; a failed turn's record is a failure. When she adds to a line of hers (map 16.17), the room is the
|
||||
//! actuator, as the mouth will be live (B1): it appends `EDIT_MARK` and her draft to that line itself, wakes no one, and
|
||||
//! records a receipt in her turn's record.
|
||||
//! records a receipt in her turn's record. When a line of hers replies to another (map 16.20.8 (D), K20), the room records
|
||||
//! the relation by the replied line's event, as the mouth will live (Bifrost B3), and refuses one not in the line's room;
|
||||
//! every view after it shows the replied line, with who said it, above hers.
|
||||
//!
|
||||
//! Her state does not move during a run: the Interpreter (C3b) and the commit (C3c) are not built. `state_after_turn`
|
||||
//! is the seam where they will. An explicit addressee (the Interpreter naming whom she speaks to) cannot be simulated
|
||||
|
|
@ -427,17 +429,29 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
}
|
||||
// A failed call is a failure, never a silence.
|
||||
let failed = report.get("error").or_else(|| render.get("failed")).or_else(|| render["persona"].get("failed")).or_else(|| render["interpreter"].get("failed")).map(|fault| fault.as_str().unwrap_or_default().to_owned());
|
||||
// What she says is the Interpreter's decision alone; who it wakes is its structured mentions and reply target.
|
||||
// What she says is the Interpreter's decision alone; who it wakes is its structured mentions and the line it replies to.
|
||||
let said: Vec<Value> = if failed.is_some() { vec![] } else { render["interpreter"]["said"].as_array().cloned().unwrap_or_default() };
|
||||
let cause = cause_word(why.as_ref().map(|why| why.cause));
|
||||
let mut spoken: Vec<String> = Vec::new();
|
||||
// The room's receipts: each line it appended, by its index, which serves as its event.
|
||||
let mut posted: Vec<Value> = Vec::new();
|
||||
let mut refused_sends: Vec<Value> = Vec::new();
|
||||
for (offset, decided) in said.iter().enumerate() {
|
||||
let room = decided["room"].as_str().unwrap_or(&here).to_owned();
|
||||
let says = decided["text"].as_str().unwrap_or_default().to_owned();
|
||||
let mentions: Vec<String> = decided["mentions"].as_array().map(|ids| ids.iter().filter_map(Value::as_str).filter(|id| cast.contains(&(*id).to_owned()) || plan.operators.contains(&(*id).to_owned())).map(str::to_owned).collect()).unwrap_or_default();
|
||||
let reply_to = decided["reply_to"].as_str().and_then(|person| lines.iter().rposition(|line| line.from == person && line.room == room));
|
||||
// The room is the reply's actuator, as the mouth will be (B3): an event not in this room refuses the send, so
|
||||
// nothing reached the room and no receipt is written.
|
||||
let reply_to = match decided["in_reply_to"]["event"].as_str() {
|
||||
None => None,
|
||||
Some(event) => match replied(&lines, event, &room) {
|
||||
Some(at) => Some(at),
|
||||
None => {
|
||||
refused_sends.push(json!({ "text": says, "in_reply_to": event, "refusal": "reply_target_not_in_room" }));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
};
|
||||
let at_ms = u64::try_from(now.timestamp_millis()).unwrap_or_default() + offset as u64;
|
||||
let to = if room == here { dm_to.clone() } else { None };
|
||||
posted.push(json!({ "event": lines.len().to_string(), "room": room, "text": says }));
|
||||
|
|
@ -460,7 +474,7 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
}
|
||||
last[at] = Some(match &failed {
|
||||
Some(failed) => json!({ "failed": failed }),
|
||||
None => json!({ "interpreter": render["interpreter"], "posted": posted, "edited": edited }),
|
||||
None => json!({ "interpreter": render["interpreter"], "posted": posted, "edited": edited, "refused_sends": refused_sends }),
|
||||
});
|
||||
let line = (!spoken.is_empty()).then(|| spoken.join(" / "));
|
||||
let outcome = if failed.is_some() { "failed" } else if line.is_some() { "spoke" } else { "silent" };
|
||||
|
|
@ -476,6 +490,12 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
Ok(json!({ "repeat": repeat + 1, "seed": seed, "transcript": transcript, "turns": turns, "metrics": metrics, "inbox": inbox }))
|
||||
}
|
||||
|
||||
/// The line a reply of hers answers, by the event the room gave it (`$fixture-{index}`, as `harness::Line::delivery` names
|
||||
/// it), when it is a line of `room`: the mouth's check under B3. None refuses the send.
|
||||
fn replied(lines: &[Line], event: &str, room: &str) -> Option<usize> {
|
||||
event.strip_prefix("$fixture-").and_then(|at| at.parse::<usize>().ok()).filter(|at| lines.get(*at).is_some_and(|line| line.room == room))
|
||||
}
|
||||
|
||||
/// The simulated room's edit of a line of `her`s, by its event (the line's index): her words after `EDIT_MARK`, the line
|
||||
/// as it stands kept whole before them. The refusal, as the mouth's would read (B1), or None when it was made.
|
||||
fn edit(lines: &mut [Line], her: &str, event: &str, added: &str) -> Option<&'static str> {
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ fn tagging(mention: bool) -> Scripted {
|
|||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return json!({ "say": [], "gaps": [] }).to_string();
|
||||
}
|
||||
json!({ "say": [{ "draft": 1, "mentions": mentions, "reply_to": null }], "gaps": [] }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": mentions, "in_reply_to": null }], "gaps": [] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ fn reaching() -> Scripted {
|
|||
}
|
||||
let start = prompt.rfind("I want to see shape number").unwrap();
|
||||
let quote = &prompt[start..=start + prompt[start..].find('.').unwrap()];
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null }], "gaps": [{ "kind": "missing_affordance", "draft": null, "quote": quote, "detail": "" }] }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null }], "gaps": [{ "kind": "missing_affordance", "draft": null, "quote": quote, "detail": "" }] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -524,6 +524,39 @@ fn the_rooms_edit_appends_to_her_own_line_only_and_every_view_reads_it() {
|
|||
assert_eq!(tail[0].body, lines[0].says, "the next view reads the amended text");
|
||||
}
|
||||
|
||||
/// Tobiah passes on Meta's opening line by replying to it with his own words; Libby says nothing.
|
||||
fn passing_on() -> Scripted {
|
||||
Scripted::new(|prompt| if is_tobiah(prompt) { "<typed>She greeted all of us, Libby.</typed>".into() } else { "She lets it be.".into() }).interpreting(|prompt| {
|
||||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return json!({ "say": [], "gaps": [] }).to_string();
|
||||
}
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": "q1", "promises": null }], "gaps": [] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
/// K20 in the simulator: the room records the reply relation by the replied line's event, as the mouth will (B3), and
|
||||
/// every later view shows Meta's line, with who said it, above Tobiah's; his line holds only his own words.
|
||||
#[test]
|
||||
fn k20_the_room_records_a_reply_and_another_minds_packet_shows_the_line_above_it() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = plan(dir.path(), "\"all_messages\"", 2, "");
|
||||
let (_, run) = run_plan(&path, &passing_on());
|
||||
let first = run["turns"].as_array().unwrap().iter().find(|turn| turn["persona"] == "Tobiah").expect("Meta's line wakes him");
|
||||
assert_eq!(first["report"]["renders"][0]["interpreter"]["said"][0]["in_reply_to"]["event"], "$fixture-0", "{}", first["report"]["renders"][0]["interpreter"]);
|
||||
let transcript = run["transcript"].as_array().unwrap();
|
||||
assert!(transcript.iter().filter(|line| line["from"] == TOBIAH).all(|line| line["says"] == "She greeted all of us, Libby."), "his line holds his words alone: {transcript:?}");
|
||||
let libby = run["turns"].as_array().unwrap().iter().find(|turn| turn["persona"] == "Libby" && turn["round"] == 2).expect("his line wakes her under all_messages");
|
||||
let heard = libby["report"]["packet"]["heard"].as_str().unwrap();
|
||||
assert!(heard.contains("> Meta (@meta:gamecult.org): \"good afternoon, everyone\"\nTobiah (@eureka:gamecult.org), replying to Meta (@meta:gamecult.org), "), "{heard}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_room_refuses_a_reply_to_an_event_not_in_the_lines_room() {
|
||||
let line = |room: &str| Line { from: LIBBY.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("#minds:x"), line("#other:x")];
|
||||
assert_eq!((replied(&lines, "$fixture-0", "#minds:x"), replied(&lines, "$fixture-1", "#minds:x"), replied(&lines, "$fixture-9", "#minds:x"), replied(&lines, "0", "#minds:x")), (Some(0), None, None, None));
|
||||
}
|
||||
|
||||
/// Tobiah leaves Self a note each turn; Libby says nothing.
|
||||
fn noting() -> Scripted {
|
||||
Scripted::new(|prompt| if is_tobiah(prompt) { "I'll leave Self a note. <typed>Meta wants the kettle softer.</typed>".into() } else { "She lets it be.".into() }).interpreting(|prompt| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue