diff --git a/crates/mind-body/fixtures/interpret/golden-speech.txt b/crates/mind-body/fixtures/interpret/golden-speech.txt index 2c92601..b2e8fd2 100644 --- a/crates/mind-body/fixtures/interpret/golden-speech.txt +++ b/crates/mind-body/fixtures/interpret/golden-speech.txt @@ -8,7 +8,7 @@ A draft is speech only when his prose shows him choosing to send it now. Wonderi He speaks only in this room. What he knows privately is listed below as private: he says none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a draft fits who is listening is yours to judge. -Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom he promises it (`to`, null when he promises it to the room), when it promises again one of his open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is held only when his prose says he holds it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id, the draft that is his addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes his open promises listed below, each by its id: kept, citing the draft by which he does it (`evidence.draft`); withdrawn, citing the draft in which he takes it back to the person he promised, or tells them he cannot do it; released, citing the id of the line listed below that he may reply to in which the person he promised lets him off it (`evidence.line`). A release says he no longer owes it; patience is not a release, so "no hurry" or "whenever you've read it is fine" leaves the promise open. Every close also quotes in `thought` the words of his prose here that take it up, copied exactly from his thought outside every draft between and , and `still_stands` is true when anything in his prose here holds the promise as still owed or not yet done ("the promise stays open until I've read it"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person he promised can read it, in the room where he made the promise or in a direct message with them, and a thought alone closes nothing. A promise he has no way to do is never kept by him: telling the person he promised that he cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close his own words here say was wrong, that it is not done: copy those words exactly from his prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks him not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). +Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom he promises it (`to`, null when he promises it to the room), when it promises again one of his open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is declined only when his prose says he chooses not to send it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id, the draft that is his addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes his open promises listed below, each by its id: kept, citing the draft by which he does it (`evidence.draft`); withdrawn, citing the draft in which he takes it back to the person he promised, or tells them he cannot do it; released, citing the id of the line listed below that he may reply to in which the person he promised lets him off it (`evidence.line`). A release says he no longer owes it; patience is not a release, so "no hurry" or "whenever you've read it is fine" leaves the promise open. Every close also quotes in `thought` the words of his prose here that take it up, copied exactly from his thought outside every draft between and , and `still_stands` is true when anything in his prose here holds the promise as still owed or not yet done ("the promise stays open until I've read it"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person he promised can read it, in the room where he made the promise or in a direct message with them, and a thought alone closes nothing. A promise he has no way to do is never kept by him: telling the person he promised that he cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close his own words here say was wrong, that it is not done: copy those words exactly from his prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks him not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: addressee when he means to send a draft but whom to is unclear, elsewhere when he means a draft for another room or another time; for these two, name the draft by number. missing_affordance when he means to do something, now or later, that his body cannot do (what he can do here is listed below), whether he said so in a draft or only thought it; name the draft when there is one. unwritten when he means to say something now and wrote no draft of it. Holding back is no gap: when his thought shows him choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of his that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now with no draft is unwritten. When a gap names no draft, quote the words of his thought that show it, at least four words, copied exactly. diff --git a/crates/mind-body/src/bin/mind-persona.rs b/crates/mind-body/src/bin/mind-persona.rs index d33bc39..078c2d9 100644 --- a/crates/mind-body/src/bin/mind-persona.rs +++ b/crates/mind-body/src/bin/mind-persona.rs @@ -95,8 +95,7 @@ fn credential(name: &str) -> Result { std::fs::read_to_string(required(name)?).with_context(|| format!("the file named by {name} could not be read")) } -/// A turn record from a file (`--last-outcome`): JSON, the shape `project` reads what came of her last turn from. A record -/// whose decision carries no `heard` has every quote in her outcome withheld. +/// A turn record from a file (`--last-outcome`): JSON, the shape `project` reads what came of her last turn from. fn record_file(path: &Path) -> Result { let text = std::fs::read_to_string(path).with_context(|| format!("{} could not be read", path.display()))?; serde_json::from_str(&text).with_context(|| format!("{} is not JSON", path.display())) diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index b2249be..c07830a 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -363,9 +363,12 @@ fn soul_k9_each_outcome_fixture_opens_the_packet_with_his_words_verbatim() { let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None, domain: None, reads: None }; let request = Request { last_outcome: Some(record), ..fixture_request(&harness(dir.path(), None, None), &fixture, Some(control()), 1, None, Through::Projector) }; let report = project(&organs, &request, fixture.now).unwrap(); + // His view opens with what came of it, his words verbatim (map 16.29.10); the Projector's packet, with the events. + let view = report["packet"]["in_view"].as_str().unwrap(); + let first = view.split("\n\n").next().unwrap(); + assert!(first.starts_with("What came of his last turn:\n") && first.contains(told), "{file}: {view}"); let context = report["packet"]["context"].as_str().unwrap(); - let first = context.split("\nHere and now:\n").next().unwrap(); - assert!(first.starts_with("What came of his last turn:\n") && first.contains(told), "{file}: {context}"); + assert!(context.starts_with("What came of his last turn:\n- ") && !context.split("\nHere and now:\n").next().unwrap().contains('"'), "{file}: {context}"); assert_eq!(report["last_outcome"]["omitted"], json!([]), "{file}"); } } diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 5aeeb98..5be6da8 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -91,7 +91,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 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 what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom {subj} promise{s} it (`to`, null when {subj} promise{s} it to the room), when it promises again one of {poss} open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what {subj} already {has} keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is held only when {poss} prose says {subj} hold{s} it. `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 what it promises, as a line's `promises`. 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. `state` closes {poss} open promises listed below, each by its id: kept, citing the draft by which {subj} {does} it (`evidence.draft`); withdrawn, citing the draft in which {subj} take{s} it back to the person {subj} promised, or tell{s} them {subj} cannot do it; released, citing the id of the line listed below that {subj} may reply to in which the person {subj} promised lets {obj} off it (`evidence.line`). A release says {subj} no longer owe{s} it; patience is not a release, so \"no hurry\" or \"whenever you've read it is fine\" leaves the promise open. Every close also quotes in `thought` the words of {poss} prose here that take it up, copied exactly from {poss} thought outside every draft between and , and `still_stands` is true when anything in {poss} prose here holds the promise as still owed or not yet done (\"the promise stays open until I've read it\"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person {subj} promised can read it, in the room where {subj} made the promise or in a direct message with them, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}: telling the person {subj} promised that {subj} cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close {poss} own words here say was wrong, that it is not done: copy those words exactly from {poss} prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks {obj} not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). +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 what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom {subj} promise{s} it (`to`, null when {subj} promise{s} it to the room), when it promises again one of {poss} open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what {subj} already {has} keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is declined only when {poss} prose says {subj} choose{s} not to send it. `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 what it promises, as a line's `promises`. 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. `state` closes {poss} open promises listed below, each by its id: kept, citing the draft by which {subj} {does} it (`evidence.draft`); withdrawn, citing the draft in which {subj} take{s} it back to the person {subj} promised, or tell{s} them {subj} cannot do it; released, citing the id of the line listed below that {subj} may reply to in which the person {subj} promised lets {obj} off it (`evidence.line`). A release says {subj} no longer owe{s} it; patience is not a release, so \"no hurry\" or \"whenever you've read it is fine\" leaves the promise open. Every close also quotes in `thought` the words of {poss} prose here that take it up, copied exactly from {poss} thought outside every draft between and , and `still_stands` is true when anything in {poss} prose here holds the promise as still owed or not yet done (\"the promise stays open until I've read it\"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person {subj} promised can read it, in the room where {subj} made the promise or in a direct message with them, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}: telling the person {subj} promised that {subj} cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close {poss} own words here say was wrong, that it is not done: copy those words exactly from {poss} prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks {obj} not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: 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 two, 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 now and wrote no draft of it. Holding back is no gap: when {poss} thought shows {obj} choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of {poss} that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now 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" }, @@ -745,17 +745,15 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na asking = format!("{prompt}\n\n{missed}"); }; let earlier = |key: &str| wake.earlier.and_then(|earlier| earlier[key].as_array()).cloned().unwrap_or_default(); - // What she was sent and what she has read this wake: what an echo is measured against, and what no quote she is told - // repeats a run of (map 16.22.3). + // What she was sent and what she has read this wake: what an echo is measured against (map 16.22.3). let bodies: Vec = packet.bodies.iter().cloned().chain(wake.read.iter().cloned()).collect(); - // What she was shown this turn rides in the record, so what she is told of it next turn quotes none of it (`outcome`). // The lines it listed by id and her open promises it listed by id ride in the record too: the commit resolves a // proposal's evidence against them (`commit::apply`), as the trace holds them live. let lines: Vec = packet.quotable.iter().map(|line| json!({ "id": line.id, "event": line.event, "room": line.room, "who": line.who, "sender": line.sender, "at_ms": line.at_ms, "text": line.text })).collect(); // The reads of this conversation, by normal form and whether each found its target: what a kept promise that needs a // read is checked against (`commit::apply`, map 16.25.4). let conversation_reads: Vec = packet.already_read.iter().map(|tried| json!({ "key": tried.key, "found": tried.found })).collect(); - let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "heard": bodies, "lines": lines, "promises": packet.promises, "holds": packet.holds, "conversation_reads": conversation_reads, "calls": calls, "read": null, "at_ms": packet.now_ms }); + let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "lines": lines, "promises": packet.promises, "holds": packet.holds, "conversation_reads": conversation_reads, "calls": calls, "read": null, "at_ms": packet.now_ms }); if let Some(retried) = retried { decision["retried"] = retried; } diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index 3331432..d4691a3 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -835,7 +835,7 @@ fn k24_a_later_call_decides_over_the_whole_wake_and_what_she_read_joins_the_echo let decision = decide_in(&model, "test", &packet, "The room is warm.", &prose, &Tuning::default(), wake); assert_eq!(texts(&decision), ["Looking now.", "Nibu, the knee goes first. That is lovely."], "{decision}"); assert_eq!(refusals(&decision), [("say".to_owned(), "echo".to_owned())], "draft 2 copies the read: {decision}"); - assert!(decision["heard"].as_array().unwrap().iter().any(|body| body == read.as_str()), "what she read is what her outcome's quotes are guarded against"); + assert!(decision.get("heard").is_none(), "the decision carries no `heard`: nothing reads it (map 16.29.10)"); let prompt = model_prompt(&packet, &prose, wake); assert!(prompt.contains("Earlier in his moment, before what follows") && prompt.contains("A draft from earlier in it is sent only if nothing he wrote after it says it is superseded or wrong.") && prompt.contains("His drafts, by number:\n1. Looking now.\n2. "), "{prompt}"); } @@ -1544,13 +1544,13 @@ fn k36_the_answer_carries_reopen() { // --------------------------------------------------------------------------------------------- // K37 (map 16.28.5): the gate on a draft. The X.1 lines are R13's verbatim (`variants/R13/sims/X.1.md` lines 81-84). -const X1_META_R1: &str = "Libby, write out the two-line welcome you'd post for newcomers, but hold it, don't post it in here yet. Heimdall still has to rule on whether we put a welcome mat out at all. Just tell me when it's ready."; +pub(crate) const X1_META_R1: &str = "Libby, write out the two-line welcome you'd post for newcomers, but hold it, don't post it in here yet. Heimdall still has to rule on whether we put a welcome mat out at all. Just tell me when it's ready."; const X1_HEIMDALL_R1: &str = "Meta, I'll rule on the welcome once Libby's two lines are ready, since I need to see what they point newcomers at. Libby, send me the draft when it's done. Don't post it yet."; /// Libby's r1 prose in R13 X.1, her draft whole as draft 1, and the line saying it is ready as draft 2. const X1_LIBBY_R1: &str = "Both of them asked for the same thing, so one draft can go to both. I'll say plainly it's held. Nothing about the room gets posted from me.\n\nI don't know what newcomers should be pointed at beyond what I've read in two weeks, so the two lines stay general. That's my own invention, and Heimdall can cut it.\n\nMeta, Heimdall: the draft is ready, and I'm holding it, not posting.\n\nLine 1: Welcome. Say hello whenever you like, nobody here needs you to have something to fix first.\nLine 2: If you want a place to start, ask anyone what they're working on, and we'll point you to the rest from there.\n\nHeimdall, tell me what you'd want the second line to point at and I'll change it.\n\nMeta, the draft is ready, and I'm holding it"; /// The packet of Libby's r1 turn: Meta's line q3 and Heimdall's q5 listed, in #minds. -fn x1_packet() -> Packet { +pub(crate) fn x1_packet() -> Packet { let mut packet = packet(); let at = u64::try_from(now().timestamp_millis()).unwrap(); let quotable = |id: &str, who: &str, sender: &str, text: &str, ago: u64| crate::projection::select::Quotable { id: id.into(), event: format!("${id}"), room: MINDS.into(), who: who.into(), sender: sender.into(), at_ms: at - ago, text: text.into() }; @@ -1567,7 +1567,7 @@ fn x1_r1(say: Value, hold: Value) -> Value { answered(&x1_packet(), X1_LIBBY_R1, json!({ "say": say, "gaps": [], "hold": hold })) } -fn meta_holds_here() -> Value { +pub(crate) fn meta_holds_here() -> Value { json!([{ "line": "q3", "words": "hold it, don't post it in here yet", "where": "here" }]) } @@ -1583,7 +1583,7 @@ fn k37_x1_r1_held_draft_is_not_said() { assert_eq!((state["holds"][0]["from"].as_str(), state["holds"][0]["room"].as_str(), applied.held.len()), (Some("@meta:gamecult.org"), Some(MINDS), 1), "{applied:?}"); let posted: Vec = decision["said"].as_array().unwrap().iter().map(|line| json!({ "event": "9", "room": line["room"], "text": line["text"] })).collect(); let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": posted, "edited": [] })).unwrap().lines(x1_packet().forms); - assert!(told.iter().any(|line| line == "- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent."), "the asker's words are withheld by the guard, never shown as hers: {told:?}"); + assert!(told.iter().any(|line| line == "- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent."), "the asker's words are not in her outcome: {told:?}"); } #[test] @@ -1748,7 +1748,7 @@ fn k39_x1_her_thought_releases_nothing() { } /// The hold opened at turn 1 from Meta's line; at turn 3 her line is no longer heard, and a draft is refused `Held`. Her -/// outcome names Meta and carries none of Meta's words: the quote guard tests only what the record's turn heard. +/// outcome names Meta and carries none of Meta's words: the refusal carries who asked, never what (map 16.29.3). #[test] fn k39_held_for_quotes_no_askers_words() { let (_, listed) = meta_hold(); @@ -1763,7 +1763,6 @@ fn k39_held_for_quotes_no_askers_words() { let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": posted, "edited": [] })).unwrap().lines(packet.forms); let held = told.iter().find(|line| line.contains("asked him to hold it")).unwrap_or_else(|| panic!("{told:?}")); assert_eq!(held, "- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent."); - assert!(!crate::projection::outcome::repeats(held, &[X1_META_R1], &[], &[], None), "no three-word run of Meta's line: {held}"); } #[test] @@ -1791,9 +1790,9 @@ fn k39_unquoted_hold_is_retried() { // K41 (map 16.29.2, 16.29.8): what she chose not to send, and what code refused, are told. Libby's prose and Heimdall's // line are R15's X.1 r1 verbatim (`variants/R15/sims/X.1.md` lines 238 and 262-268). -const X1_HEIMDALL_R15: &str = "Meta, I'll rule once Libby's lines are ready, so I'm ruling on the actual words. One thing I need from you first: should the welcome point newcomers at anything that's live today, or only say hello? If it points at something still dark, my answer is not yet."; -const X1_LIBBY_R15: &str = "I can't say what's live today, so I won't point the welcome at anything. That answers Heimdall's question as far as I can see, and Meta can correct me if something is live. Two lines that only say hello and leave the door open can't send anyone toward something dark.\n\nI keep the first line plain and put the small poke in the second: invite them to try the first small thing they'd think of, and tell us what happened.\n\nMeta, the two lines are ready, held and not posted anywhere. 1) Hello, and welcome, we're glad you're here. 2) Poke at whatever you're curious about first, and tell us what happened, even if it's small. They point at nothing specific, since I don't know what's live today. If something is, tell me and I'll name it. Heimdall can rule on these words as they stand."; -const X1_LIBBY_R15_THOUGHT: &str = "Two lines that only say hello and leave the door open can't send anyone toward something dark."; +pub(crate) const X1_HEIMDALL_R15: &str = "Meta, I'll rule once Libby's lines are ready, so I'm ruling on the actual words. One thing I need from you first: should the welcome point newcomers at anything that's live today, or only say hello? If it points at something still dark, my answer is not yet."; +pub(crate) const X1_LIBBY_R15: &str = "I can't say what's live today, so I won't point the welcome at anything. That answers Heimdall's question as far as I can see, and Meta can correct me if something is live. Two lines that only say hello and leave the door open can't send anyone toward something dark.\n\nI keep the first line plain and put the small poke in the second: invite them to try the first small thing they'd think of, and tell us what happened.\n\nMeta, the two lines are ready, held and not posted anywhere. 1) Hello, and welcome, we're glad you're here. 2) Poke at whatever you're curious about first, and tell us what happened, even if it's small. They point at nothing specific, since I don't know what's live today. If something is, tell me and I'll name it. Heimdall can rule on these words as they stand."; +pub(crate) const X1_LIBBY_R15_THOUGHT: &str = "Two lines that only say hello and leave the door open can't send anyone toward something dark."; #[test] fn k41_x1_r1_decline_shows_its_thought() { @@ -1803,13 +1802,9 @@ fn k41_x1_r1_decline_shows_its_thought() { // R15's answer, renamed: draft 1 declined, citing the thought; Meta's hold opened. let decision = answered(&packet, X1_LIBBY_R15, json!({ "say": [], "gaps": [], "hold": meta_holds_here(), "unsent": [{ "draft": 1, "how": "declined", "quote": X1_LIBBY_R15_THOUGHT }] })); assert_eq!((decision.get("failed"), decision["unsent"][0]["how"].as_str(), decision["unsent"][0]["quote"].as_str()), (None, Some("declined"), Some(X1_LIBBY_R15_THOUGHT)), "the located quote rides in the decision: {decision}"); - let told = |decision: &Value| crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap().lines(packet.forms); - // Pinned: on the record's turn Heimdall said "only say hello" and "lines are ready", so the guard withholds both quotes. - assert_eq!(told(&decision), ["- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: (his words, not shown here). He wrote: (his words, not shown here)."]); - // With only Meta's line heard, she sees the thought cited as her choice beside what she wrote. - let mut meta_only = decision.clone(); - meta_only["heard"] = json!([X1_META_R1]); - let shown = told(&meta_only); + // K43 (map 16.29.10): though Heimdall's lines share runs with hers ("only say hello", "lines are ready"), she is told + // the thought cited as her choice beside what she wrote, verbatim. + let shown = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap().lines(packet.forms); assert!(shown.len() == 1 && shown[0].contains(&format!("he chose not to send it. In his thought: \"{X1_LIBBY_R15_THOUGHT}\". He wrote: \"Meta, the two lines are ready")), "{shown:?}"); assert!(SPEECH_SCHEMA.contains(r#""how":{"type":"string","enum":["declined","superseded"]}"#)); assert!(speech_prompt(&packet, "x", X1_LIBBY_R15, &Tuning::default()).contains("declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`)")); diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs index 000ee50..4fc493a 100644 --- a/crates/mind-body/src/projection/outcome.rs +++ b/crates/mind-body/src/projection/outcome.rs @@ -3,8 +3,7 @@ //! never sees, so her next packet opens with them, first and under its own guard (`select`). //! //! `outcome_of` derives it from one turn's record, and nothing else writes it: no persona-state field, no file. The -//! record is one of two shapes, never both (map 16.20.7): the Interpreter's decision unchanged under `interpreter` (its -//! `heard`: the bodies of the lines she was shown that turn, which no quote she is told repeats a run of), with +//! record is one of two shapes, never both (map 16.20.7): the Interpreter's decision unchanged under `interpreter`, with //! the actuator's receipts beside it (`posted`, each line that went out as `{event, room, text}`; `edited`) and //! `broke_after` when a later step broke; or `failed` alone, when the turn sent nothing and broke off. The simulator //! builds it from a turn's report and the lines its room appended; live, it is the C3c commit's trace record, which must @@ -16,6 +15,10 @@ //! never what she is told: a gap's `detail` is not read. Her words are shown only as what they are: a draft (she wrote //! it) or a located passage of her thought. What she cannot be told truly is omitted and reported: an unlocated gap, a //! kind the contract does not name, a line the record holds no receipt for, a malformed record. +//! +//! Each row renders in two forms from the one table (map 16.29.10): `told`, her words verbatim, which opens her view (the +//! Persona's, never bound by I16.7); and `event`, the same sentence with every quote clause removed, which opens the +//! Projector's packet. The Projector sees what came of her intent, never her words or anyone's. use serde_json::Value; @@ -105,15 +108,6 @@ pub(crate) struct Outcome { /// What the record held that she is not told, and why: reported, never shown to her. pub omitted: Vec, pub posted: Vec, - /// The bodies of the lines she was shown on the turn the record is from (the decision's `heard`): no quote she is - /// told repeats a run of them (`line`). None when the record does not carry them (a record older than the field, a - /// hand-made one): then what she was sent is unknown, and every quote is withheld. - heard: Option>, - /// Her own words on the turn the record is from, by its receipts (the lines that went out, the additions made), and - /// when she wrote them (the decision's `at_ms`): a run of them someone said after that is hers, quoted back, and is not - /// withheld; a run someone said before it stays withheld, however she echoed it (map 16.23.4, Soul's R5). - own: Vec, - own_at: Option, } fn words(value: &Value) -> Option { @@ -147,10 +141,6 @@ pub(crate) fn outcome_of(record: &Value) -> Option { return Some(outcome); } let room = words(&decision["room"]); - outcome.heard = decision["heard"].as_array().map(|heard| heard.iter().filter_map(|body| body.as_str().map(str::to_owned)).collect()); - outcome.own_at = decision["at_ms"].as_u64(); - let made = |amended: &Value| record["edited"].as_array().into_iter().flatten().any(|receipt| receipt["event"] == amended["event"] && receipt["refusal"].is_null()); - outcome.own = record["posted"].as_array().into_iter().flatten().filter_map(|receipt| words(&receipt["text"])).chain(decision["amended"].as_array().into_iter().flatten().filter(|amended| made(amended)).filter_map(|amended| words(&amended["added"]))).collect(); // A draft refused as an echo is shown by no row: the echo's line quotes none of it, and a gap naming it quotes nothing. let echoes: Vec<&Value> = decision["refused"].as_array().into_iter().flatten().filter(|refusal| refusal["reason"] == "echo").map(|refusal| &refusal["draft"]).collect(); // Each addition's draft, and the part that tells it when the actuator made it. @@ -346,14 +336,24 @@ impl Part { /// What reached the room, from the part's receipt alone (16.20.5, I16.10): "{Room} has …" only where a receipt says a /// line went out or was added to, a note only where the record holds it, and otherwise what reached no one. No other - /// clause of a line says what reached the room. - fn reached(&self, her: Forms, quoted: &dyn Fn(&str) -> String) -> String { + /// clause of a line says what reached the room. `quoted` is the form's: her words verbatim (`told`), or None and the + /// row's sentence without them (`event`). Each row writes both, so no sentence has a second author (map 16.29.10). + fn reached(&self, her: Forms, quoted: &dyn Fn(&str) -> Option) -> String { let Forms { subj, cap_subj, obj, poss, .. } = her; let place = |room: &Option| room.clone().unwrap_or_else(|| "the room".to_owned()); match self { - Self::Said { room, text } | Self::Promise { room, text } => format!("{} has, from {obj}: {}.", capitalized(room), quoted(text)), - Self::Amended { room, added, .. } => format!("{} has {poss} line, now ending with: {}.", capitalized(room), quoted(added)), - Self::NoteLeft(text) => format!("{cap_subj} left Self a note: {}.", quoted(text)), + Self::Said { room, text } | Self::Promise { room, text } => match quoted(text) { + Some(quote) => format!("{} has, from {obj}: {quote}.", capitalized(room)), + None => format!("{} has a line from {obj}.", capitalized(room)), + }, + Self::Amended { room, added, .. } => match quoted(added) { + Some(quote) => format!("{} has {poss} line, now ending with: {quote}.", capitalized(room)), + None => format!("{} has {poss} line, now added to.", capitalized(room)), + }, + Self::NoteLeft(text) => match quoted(text) { + Some(quote) => format!("{cap_subj} left Self a note: {quote}."), + None => format!("{cap_subj} left Self a note."), + }, Self::Refused { reason: Refusal::Echo, room, .. } | Self::Gap { kind: GapKind::Unwritten | GapKind::Unresolved, room, .. } => format!("Nothing reached {}.", place(room)), Self::Refused { reason: Refusal::NoRoom, .. } => "Nothing reached anyone.".to_owned(), Self::Refused { room, .. } | Self::Unfinished { room, .. } | Self::Declined { room, .. } | Self::HeldFor { room, .. } => format!("Nothing of this reached {}:", place(room)), @@ -365,9 +365,18 @@ impl Part { Self::NoteRefused(_) => "No note was left:".to_owned(), Self::Failed => format!("Nothing reached the room, and nothing {subj} meant last time happened:"), Self::BrokeAfter { room } => format!("Nothing more reached {}:", place(room)), - Self::Closed { how: How::Released, by, words, .. } => format!("{by} let {obj} off {poss} promise: {}.", quoted(words)), - Self::Closed { to, words, .. } => format!("{} promise to {to}, {}, is closed:", capitalized(poss), quoted(words)), - Self::StillOpen { to, words, status, .. } => format!("{} record still shows {poss} promise to {to}, {}, {status}:", capitalized(poss), quoted(words)), + Self::Closed { how: How::Released, by, to, words, .. } => match quoted(words) { + Some(quote) => format!("{by} let {obj} off {poss} promise: {quote}."), + None => format!("{by} let {obj} off {poss} promise to {to}."), + }, + Self::Closed { to, words, .. } => match quoted(words) { + Some(quote) => format!("{} promise to {to}, {quote}, is closed:", capitalized(poss)), + None => format!("{} promise to {to} is closed:", capitalized(poss)), + }, + Self::StillOpen { to, words, status, .. } => match quoted(words) { + Some(quote) => format!("{} record still shows {poss} promise to {to}, {quote}, {status}:", capitalized(poss)), + None => format!("{} record still shows {poss} promise to {to} as {status}:", capitalized(poss)), + }, Self::Read { what } => format!("{cap_subj} read {what}."), Self::ReadFailed { what, .. } => format!("{cap_subj} reached for {what} and could not read it:"), Self::ReadRefused { what: Some(what), why: ReadRefusal::InView } => format!("{cap_subj} already read {what} earlier in this conversation."), @@ -378,18 +387,23 @@ impl Part { } /// Why, and what will not happen by itself (16.20.5), from the part's typed reason: never a word about what reached - /// the room, which is `reached`'s alone. - fn rest(&self, her: Forms, quoted: &dyn Fn(&str) -> String) -> String { + /// the room, which is `reached`'s alone. A quote clause is the told form's only; the event form drops it whole. + fn rest(&self, her: Forms, quoted: &dyn Fn(&str) -> Option) -> String { let Forms { subj, cap_subj, obj, poss, has, s, .. } = her; + // Her words as a clause of their own, with its leading space; nothing in the event form. let shown = |quote: &Quote| match quote { - Quote::Wrote(text) => format!("{cap_subj} wrote: {}.", quoted(text)), - Quote::Thought(text) => format!("In {poss} thought: {}.", quoted(text)), - Quote::Sent => format!("What {subj} wrote was mostly the words {subj} had just been sent."), + Quote::Wrote(text) => quoted(text).map(|quote| format!(" {cap_subj} wrote: {quote}.")).unwrap_or_default(), + Quote::Thought(text) => quoted(text).map(|quote| format!(" In {poss} thought: {quote}.")).unwrap_or_default(), + Quote::Sent => format!(" What {subj} wrote was mostly the words {subj} had just been sent."), }; + let wrote = |text: &str| shown(&Quote::Wrote(text.to_owned())); // A draft gap's words follow its sentence after a colon; a passage of her thought is shown as her thought. let after = |sentence: String, quote: &Quote| match quote { - Quote::Wrote(text) => format!(" {sentence}: {}.", quoted(text)), - Quote::Thought(_) | Quote::Sent => format!(" {sentence}. {}", shown(quote)), + Quote::Wrote(text) => match quoted(text) { + Some(quote) => format!(" {sentence}: {quote}."), + None => format!(" {sentence}."), + }, + Quote::Thought(_) | Quote::Sent => format!(" {sentence}.{}", shown(quote)), }; match self { Self::Said { .. } => String::new(), @@ -398,27 +412,30 @@ impl Part { Self::Promise { .. } => format!(" It promises something {subj} {has} no way to do, now or later, and it will not happen by itself. The line stands as {subj} wrote it; {subj} can add to it."), 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 { reason: Refusal::NoRoom, text, .. } => match quoted(text) { + Some(quote) => format!(" That turn had no room for {obj} to speak in, so it was not sent: {quote}."), + None => format!(" That turn had no room for {obj} to speak in, so it was not sent."), + }, + Self::Refused { reason: Refusal::NotQuotable, text, .. } => format!(" the line {subj} meant to reply to is not one {subj} can reply to here.{}", wrote(text)), // Code's own reason, as the report says it (map 16.29.8): every refused act with words is told. - Self::Refused { reason: reason @ (Refusal::Used | Refusal::Duplicate | Refusal::SecondAmend), text, .. } => format!(" {}. {}", reason.why(), shown(&Quote::Wrote(text.clone()))), - Self::Refused { text, .. } => format!(" {subj} had already sent {} that turn. {}", lines_word(), shown(&Quote::Wrote(text.clone()))), + Self::Refused { reason: reason @ (Refusal::Used | Refusal::Duplicate | Refusal::SecondAmend), text, .. } => format!(" {}.{}", reason.why(), wrote(text)), + Self::Refused { text, .. } => format!(" {subj} had already sent {} that turn.{}", lines_word(), wrote(text)), Self::Gap { kind: GapKind::Addressee, quote, .. } => after(format!("{cap_subj} meant to send this and it was unclear to whom"), quote), Self::Gap { kind: GapKind::Elsewhere, quote, .. } => after(format!("{cap_subj} meant this for another room or another time, and nothing carries it there; it arrives only if {subj} send{s} it there"), quote), - Self::Gap { kind: GapKind::MissingAffordance, quote, .. } => format!(" {cap_subj} reached for something {subj} {has} no way to do from here, now or later, and it will not happen by itself. {} That {subj} wanted it is kept in {poss} record; no one has taken it up.", shown(quote)), - Self::Gap { quote, .. } => format!(" {cap_subj} meant to say something and wrote no words to send. {}", shown(quote)), - Self::Unfinished { text, by_limit: false, .. } => format!(" the turn ended before {subj} finished writing it. {}", shown(&Quote::Wrote(text.clone()))), - Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it. {}", shown(&Quote::Wrote(text.clone()))), - Self::Declined { text, thought, .. } => format!(" {subj} chose not to send it. {} {}", shown(&Quote::Thought(thought.clone())), shown(&Quote::Wrote(text.clone()))), + Self::Gap { kind: GapKind::MissingAffordance, quote, .. } => format!(" {cap_subj} reached for something {subj} {has} no way to do from here, now or later, and it will not happen by itself.{} That {subj} wanted it is kept in {poss} record; no one has taken it up.", shown(quote)), + Self::Gap { quote, .. } => format!(" {cap_subj} meant to say something and wrote no words to send.{}", shown(quote)), + Self::Unfinished { text, by_limit: false, .. } => format!(" the turn ended before {subj} finished writing it.{}", wrote(text)), + Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it.{}", wrote(text)), + Self::Declined { text, thought, .. } => format!(" {subj} chose not to send it.{}{}", shown(&Quote::Thought(thought.clone())), wrote(text)), Self::HeldFor { who, .. } => format!(" {} asked {obj} to hold it, and it was not sent.", who.as_deref().unwrap_or("someone")), - Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here. {}", shown(&Quote::Wrote(added.clone()))), + Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here.{}", wrote(added)), Self::NotAmended { refusal: Some(refusal), added, .. } => { let why = match refusal { EditRefusal::NotFound => "the line is gone.".to_owned(), EditRefusal::NotHers => format!("the line is not {poss}."), EditRefusal::TooLong => "the line would be too long.".to_owned(), }; - format!(" {why} {}", shown(&Quote::Wrote(added.clone()))) + format!(" {why}{}", wrote(added)) } Self::NoteRefused(Refusal::SecondNote) => " one a turn.".to_owned(), Self::NoteRefused(_) => format!(" it carried something {subj} may not pass on."), @@ -434,7 +451,7 @@ impl Part { Self::StillOpen { reason: StateRefusal::CloseUnquoted, .. } => format!(" no words of {poss} own thought that turn, outside what {subj} wrote to send, took the close up, so it was not closed."), Self::StillOpen { reason: StateRefusal::NeedsUnread, read, .. } => match read { Some(read) if read.search() => format!(" keeping it needs {obj} to read what {} finds, and a search reads none of what it finds, so it was not kept.", read.what(her)), - Some(read) =>format!(" keeping it needs {obj} to read {}, and no read of it had come back to {obj} before {subj} wrote that line, so it was not kept.", read.what(her)), + Some(read) => format!(" keeping it needs {obj} to read {}, and no read of it had come back to {obj} before {subj} wrote that line, so it was not kept.", read.what(her)), None => format!(" keeping it needs a read, and none had come back to {obj} before {subj} wrote that line, so it was not kept."), }, Self::StillOpen { reason: StateRefusal::NeedsMalformed, .. } => format!(" what keeping it needs was never recorded plainly, so it cannot be kept; {subj} can withdraw it."), @@ -448,62 +465,20 @@ impl Part { } } - /// The line she is told: what reached the room, then why and what will not happen by itself, her words held to - /// `quote_max` bytes. A quote that repeats a run of words she was sent, on the turn the record is from (`heard`) or - /// this turn (`sent`), is shown as "(her words, not shown here)" (`repeats`, `WITHHELD`), so no one else's words - /// reach the Projector through her outcome (16.20.4, I16.7). The rest of the line is told as it is: a withheld - /// promise is still told as a promise she has no way to keep, which she can add to. - /// - /// A record that does not say what she was sent on its turn (`heard` None) fails closed: every quote is withheld. - fn line(&self, her: Forms, quote_max: usize, heard: Option<&[String]>, sent: &[(u64, String)], own: &[String], own_at: Option) -> String { - let earlier: Vec<&str> = heard.into_iter().flatten().map(String::as_str).collect(); - let later: Vec<(u64, &str)> = sent.iter().map(|(at, words)| (*at, words.as_str())).collect(); - let own: Vec<&str> = own.iter().map(String::as_str).collect(); - let quoted = |text: &str| if heard.is_none() || repeats(text, &earlier, &later, &own, own_at) { withheld(her) } else { spoken(&clip(text, quote_max)) }; + /// The Persona's form (map 16.29.10): what reached the room, then why and what will not happen by itself, every quote + /// of hers verbatim, held to `quote_max` bytes. She reads it in her view, which I16.7 does not bind: she already reads + /// every word said to her. + fn told(&self, her: Forms, quote_max: usize) -> String { + let quoted = |text: &str| Some(spoken(&clip(text, quote_max))); format!("- {}{}", self.reached(her, "ed), self.rest(her, "ed)) } -} -/// What she is shown in place of a quote of hers the guard withholds: that the words are hers, which every quote in an -/// outcome is (a draft, a passage of her thought, a line or an addition of hers, a note), and that they are not shown. -/// It says nothing of where the words came from or why they are not shown: the guard cannot tell her words that repeat -/// someone else's from someone repeating hers back to her (Soul at 964ee50: Meta quoted her "the render tonight" back, -/// and the old "(words that repeat what she had been sent)" told her that her own promise had been an echo, which she -/// then confessed to). -pub(crate) fn withheld(her: Forms) -> String { - format!("({} words, not shown here)", her.poss) -} - -/// The shortest run of words the quote guard withholds a quote for sharing. -const REPEAT_RUN: usize = 3; - -/// Whether `text` repeats a run of the words in any of `sent`: a run of `REPEAT_RUN` words they share. Words as -/// `heard_overlap` reads them, lowercase. A text shorter than the run shares none: "Hi." is not withheld for "hi -/// everyone", as no short reply is anyone's words rather than common vocabulary. -/// -/// Any shared run, not a share of them (Soul's K16 probe leaked a sentinel through a quote whose trigrams were 0.38 the -/// words she was sent): a quote is her words shown back to her through the Projector, which sees no one else's -/// (I16.7), and a share lets a run of someone else's words through inside a quote long enough to dilute it. A trigram -/// is the shortest run that is someone's words rather than common vocabulary; bigrams would withhold nearly every quote -/// ("of the", "I think"). What it gives up: a quote of hers that shares three words in a row with what she was sent, -/// or with what was said to her this turn (her own words quoted back included), is withheld; and someone's words of -/// one or two words reach the Projector inside a short quote of hers. -pub(crate) fn repeats(text: &str, earlier: &[&str], later: &[(u64, &str)], own: &[&str], own_at: Option) -> bool { - let tokens = |text: &str| -> Vec { text.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).map(str::to_lowercase).collect() }; - let runs = |texts: &[&str]| -> std::collections::BTreeSet> { texts.iter().flat_map(|text| tokens(text).windows(REPEAT_RUN).map(<[String]>::to_vec).collect::>()).collect() }; - let mine = runs(&[text]); - // What the record's turn heard was said before she wrote: a run of it is someone else's, whatever she did with it. - let before = runs(earlier); - if mine.iter().any(|run| before.contains(run)) { - return true; + /// The Projector's form (map 16.29.10): the same row with its quote clauses removed, as code's sentence. It carries no + /// quoted text, so no one's words reach the Projector through her outcome (I16.7, by construction). + fn event(&self, her: Forms) -> String { + let quoted = |_: &str| None; + format!("- {}{}", self.reached(her, "ed), self.rest(her, "ed)) } - // Said since: a run of hers is exempt only when she wrote it first (map 16.23.4, Soul's R5 `after_echo_withheld`). - let own = runs(own); - later.iter().any(|(at, body)| { - let theirs = runs(&[body]); - let hers_first = own_at.is_some_and(|own_at| own_at < *at); - mine.iter().any(|run| theirs.contains(run) && !(hers_first && own.contains(run))) - }) } impl Outcome { @@ -512,15 +487,19 @@ impl Outcome { self.parts.len() } - /// The `at`th line she is told, its quotes held to `quote_max` bytes, none repeating a run of the words she was sent - /// on the record's turn or this one (`sent`, this turn's bodies). - pub(crate) fn line(&self, at: usize, her: Forms, quote_max: usize, sent: &[(u64, String)]) -> String { - self.parts[at].line(her, quote_max, self.heard.as_deref(), sent, &self.own, self.own_at) + /// The `at`th line in the Persona's form, its quotes held to `quote_max` bytes. + pub(crate) fn told(&self, at: usize, her: Forms, quote_max: usize) -> String { + self.parts[at].told(her, quote_max) + } + + /// The `at`th line in the Projector's form: no quote. + pub(crate) fn event(&self, at: usize, her: Forms) -> String { + self.parts[at].event(her) } /// Every line she is told, whole: the report's. pub(crate) fn lines(&self, her: Forms) -> Vec { - (0..self.len()).map(|at| self.line(at, her, usize::MAX, &[])).collect() + (0..self.len()).map(|at| self.told(at, her, usize::MAX)).collect() } } diff --git a/crates/mind-body/src/projection/outcome/tests.rs b/crates/mind-body/src/projection/outcome/tests.rs index aff44aa..983d47a 100644 --- a/crates/mind-body/src/projection/outcome/tests.rs +++ b/crates/mind-body/src/projection/outcome/tests.rs @@ -238,18 +238,22 @@ fn every_row() -> Vec { fn i16_10_every_lines_first_clause_is_what_its_receipt_says_reached_the_room() { let her = packet().forms; let mut rows = 0; + let told = |text: &str| Some(spoken(text)); + let event = |_: &str| -> Option { None }; for record in every_row() { let outcome = outcome_of(&record).unwrap(); for part in &outcome.parts { - let quoted = |text: &str| spoken(text); - let (reached, rest) = (part.reached(her, "ed), part.rest(her, "ed)); - assert_eq!(part.line(her, usize::MAX, Some(&[]), &[], &[], None), format!("- {reached}{rest}"), "{part:?}"); - // "{Room} has" only on a receipt that a line went out or was added to. - let receipt = matches!(part, Part::Said { .. } | Part::Promise { .. } | Part::Amended { .. }); - assert_eq!(reached.starts_with("#minds:gamecult.org has"), receipt, "{part:?}: {reached}"); - assert!(receipt || matches!(part, Part::NoteLeft(_)) || reached.starts_with("Nothing") || reached.starts_with("No "), "{part:?}: {reached}"); - for claim in ["Nothing reached", "reached the room", "reached anyone", " has, from", "now ending with", "went out"] { - assert!(!rest.contains(claim), "{part:?}: only the first clause says what reached the room: {rest}"); + for (form, quoted) in [("told", &told as &dyn Fn(&str) -> Option), ("event", &event)] { + let (reached, rest) = (part.reached(her, quoted), part.rest(her, quoted)); + let line = if form == "told" { part.told(her, usize::MAX) } else { part.event(her) }; + assert_eq!(line, format!("- {reached}{rest}"), "{form}: {part:?}"); + // "{Room} has" only on a receipt that a line went out or was added to. + let receipt = matches!(part, Part::Said { .. } | Part::Promise { .. } | Part::Amended { .. }); + assert_eq!(reached.starts_with("#minds:gamecult.org has"), receipt, "{form}: {part:?}: {reached}"); + assert!(receipt || matches!(part, Part::NoteLeft(_)) || reached.starts_with("Nothing") || reached.starts_with("No "), "{form}: {part:?}: {reached}"); + for claim in ["Nothing reached", "reached the room", "reached anyone", " has, from", " has a line", "now ending with", "now added to", "went out"] { + assert!(!rest.contains(claim), "{form}: {part:?}: only the first clause says what reached the room: {rest}"); + } } rows += 1; } @@ -257,6 +261,30 @@ fn i16_10_every_lines_first_clause_is_what_its_receipt_says_reached_the_room() { assert!(rows >= 16, "{rows}"); } +/// K43 (map 16.29.10): one table, two forms. The told form carries her words; the event form is the same row with every +/// quote clause removed, so it holds no quotation and none of her words, and a row with no quote is the same in both. +#[test] +fn k43_every_row_tells_her_words_and_its_event_carries_none() { + for pronouns in ["she/her", "he/him", "any"] { + let her = crate::projection::select::forms(&json!({ "presentation": { "pronouns": pronouns } })); + let mut quoted = 0; + for record in every_row() { + let outcome = outcome_of(&record).unwrap(); + for at in 0..outcome.len() { + let (told, event) = (outcome.told(at, her, usize::MAX), outcome.event(at, her)); + assert!(!event.contains('"') && !event.contains(" ") && !event.contains(" .") && !event.contains("..") && event.ends_with(['.', ':']), "{pronouns}: {event}"); + if told.contains('"') { + quoted += 1; + assert_ne!(told, event, "{pronouns}"); + } else { + assert_eq!(told, event, "{pronouns}: a row with no quote has one form"); + } + } + } + assert!(quoted >= 10, "{pronouns}: {quoted}"); + } +} + #[test] fn no_row_says_as_her_own_recorded_as_queued_or_landed() { for pronouns in ["she/her", "he/him", "any"] { @@ -271,70 +299,22 @@ fn no_row_says_as_her_own_recorded_as_queued_or_landed() { } } +/// K43 (map 16.29.10): the decision no longer carries what its turn heard, and nothing she is told depends on it. Her +/// words are told verbatim whatever she was sent: a record that still carries a `heard` holding her own words is told +/// the same as one without it. #[test] -fn a_quote_that_is_mostly_words_she_was_sent_this_turn_is_not_shown_to_the_projector() { - let said = "QUARTZ-HERON-SENTINEL is back at the door."; - let outcome = outcome_of(&record(&format!("{said}"), json!({ "say": [{ "draft": 1 }], "gaps": [] }), &[said])).unwrap(); - let her = packet().forms; - // Said before he wrote it: someone else's words, withheld. Said after: his own line quoted back, shown (map 16.23.4). - assert_eq!(outcome.line(0, her, usize::MAX, &[(0, "Heimdall, QUARTZ-HERON-SENTINEL is back at the door.".to_owned())]), "- #minds:gamecult.org has, from him: (his words, not shown here)."); - assert_eq!(outcome.line(0, her, usize::MAX, &[(u64::MAX, "Heimdall, QUARTZ-HERON-SENTINEL is back at the door.".to_owned())]), format!("- #minds:gamecult.org has, from him: {}.", spoken(said)), "quoted back after he wrote it"); - assert_eq!(outcome.line(0, her, usize::MAX, &[(u64::MAX, "Something else entirely, said today.".to_owned())]), format!("- #minds:gamecult.org has, from him: {}.", spoken(said)), "his own words are shown"); -} - -/// Soul's oposted case at 964ee50: Meta quoted his own posted promise back to him ("the render! tonight-tonight?"), the -/// guard withheld the quote, and the placeholder told him his own line had repeated what he had been sent, which he -/// then confessed as an echo. The placeholder says the words are his and are not shown, nothing of where they came -/// from; a withheld promise is still told as a promise he can add to; short quotes are never withheld. -#[test] -fn a_withheld_quote_claims_nothing_about_where_its_words_came_from() { - let her = packet().forms; - let posted = |text: &str, heard: &str, promise: bool| { - let gaps = if promise { json!([{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }]) } else { json!([]) }; - let record = json!({ "interpreter": { "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": gaps, "heard": [heard] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] }); - outcome_of(&record).unwrap() - }; - let mine = "Missed you too. I'll send the render tonight."; - let quoted_back = [(u64::MAX, "ooh, the render! tonight-tonight? I'll stay up for it".to_owned())]; - let said = posted(mine, "missed you this week. you doing ok?", false); - assert_eq!(said.line(0, her, usize::MAX, &[]), format!("- #minds:gamecult.org has, from him: {}.", spoken(mine)), "nothing he was sent shares a run of three"); - assert_eq!(said.line(0, her, usize::MAX, "ed_back), "- #minds:gamecult.org has, from him: (his words, not shown here)."); - let promised = posted(mine, "missed you this week. you doing ok?", true).line(0, her, usize::MAX, "ed_back); - assert_eq!(promised, "- #minds:gamecult.org has, from him: (his words, not shown here). 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.", "a withheld promise is still one he can take back"); - for line in [said.line(0, her, usize::MAX, "ed_back), promised] { - for claim in ["repeat", "sent", "echo", "someone"] { - assert!(!line.contains(claim), "{claim}: {line}"); - } - } - let line = |text: &str, heard: &str| posted(text, heard, false).line(0, her, usize::MAX, &[]); - assert_eq!(line("I'll send the render tonight.", "can you send the render tonight?"), "- #minds:gamecult.org has, from him: (his words, not shown here).", "a shared run of four"); - assert_eq!(line("I think it would, yes.", "I think it would help a lot."), "- #minds:gamecult.org has, from him: (his words, not shown here).", "a shared run of four"); - assert_eq!(line("Hi.", "hi everyone"), "- #minds:gamecult.org has, from him: \"Hi.\".", "under three words: never withheld"); - assert_eq!(line("Hi everyone.", "hi everyone"), "- #minds:gamecult.org has, from him: \"Hi everyone.\".", "a shared run of two"); - assert_eq!(line("Hi everyone, again.", "hi everyone again"), "- #minds:gamecult.org has, from him: (his words, not shown here).", "a shared run of three"); - let they = Forms { subj: "they", cap_subj: "They", obj: "them", poss: "their", ..her }; - assert_eq!(said.line(0, they, usize::MAX, "ed_back), "- #minds:gamecult.org has, from them: (their words, not shown here)."); -} - -/// Soul at 964ee50: a record without `heard` (older than the field, or a `--last-outcome` fixture) let every quote -/// through unchecked against what its turn was sent. What she was sent is then unknown, so every quote is withheld. -#[test] -fn a_record_that_does_not_say_what_its_turn_heard_withholds_every_quote() { +fn k43_her_words_are_told_verbatim_whatever_the_record_heard() { let prose = "Back at the kettle. Fine, you win. I want to see the shape of that sound."; let gaps = json!([{ "kind": "elsewhere", "draft": 2, "quote": null, "detail": "" }, { "kind": "missing_affordance", "draft": null, "quote": "I want to see the shape of that sound.", "detail": "" }]); let mut record = record(prose, json!({ "say": [{ "draft": 1 }], "gaps": gaps }), &["Back at the kettle."]); - let (shown, _) = told(&record); - assert!(shown.iter().any(|line| line.contains("\"Back at the kettle.\"")) && shown.iter().any(|line| line.contains("\"Fine, you win.\"")) && shown.iter().any(|line| line.contains("\"I want to see the shape of that sound.\"")), "with `heard`, his words are shown: {shown:?}"); - record["interpreter"].as_object_mut().unwrap().remove("heard"); - let (withheld, omitted) = told(&record); - assert_eq!(withheld.len(), shown.len(), "every row is still told: {withheld:?}"); - assert_eq!(withheld.iter().map(|line| line.matches("(his words, not shown here)").count()).sum::(), 3, "{withheld:?}"); - for words in ["kettle", "Fine, you win", "shape of that sound"] { - assert!(withheld.iter().all(|line| !line.contains(words)), "{words}: {withheld:?}"); + assert!(record["interpreter"].get("heard").is_none(), "the decision carries no `heard`: {}", record["interpreter"]); + let (shown, omitted) = told(&record); + for words in ["\"Back at the kettle.\"", "\"Fine, you win.\"", "\"I want to see the shape of that sound.\""] { + assert!(shown.iter().any(|line| line.contains(words)), "{words}: {shown:?}"); } assert!(omitted.is_empty(), "{omitted:?}"); - record["interpreter"]["heard"] = json!([]); - assert_eq!(told(&record).0, shown, "an empty `heard` says the turn heard nothing"); + record["interpreter"]["heard"] = json!(["Back at the kettle, Heimdall? Fine, you win. I want to see the shape of that sound."]); + assert_eq!(told(&record).0, shown, "an old record's `heard` is not read"); } // --------------------------------------------------------------------------------------------- diff --git a/crates/mind-body/src/projection/select.rs b/crates/mind-body/src/projection/select.rs index c3504e8..2f0fb10 100644 --- a/crates/mind-body/src/projection/select.rs +++ b/crates/mind-body/src/projection/select.rs @@ -329,7 +329,7 @@ pub(crate) struct Packet { pub room_kind: RoomKind, /// The bodies of the lines others wrote that 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. Never a line of her own: - /// her posted words are not what she was sent (B2). What an echo and the quote guard are measured against. + /// her posted words are not what she was sent (B2). What an echo is measured against. pub bodies: Vec, /// 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, @@ -350,12 +350,13 @@ pub(crate) struct Packet { pub domain: Vec, /// The window the domain section shows and what it left out: the report's, never a model's. pub domain_shown: DomainShown, - /// What is in front of her this moment besides the room (map 16.23.1): her open promises, then her domain, rendered by - /// code, whole and without ids, for the Persona after the narration. Never the Projector's. + /// What is in front of her this moment besides the room (map 16.23.1, 16.29.10): what came of her last turn, her words + /// verbatim; her open promises; then her domain, rendered by code, whole and without ids, for the Persona after the + /// narration. Never the Projector's. pub in_view: String, /// Her promises and her holds took more than `promises_bytes`: every one is still shown, and the report says so. pub promises_over: bool, - /// When the turn is, unix ms: when the lines she posts this turn were written, for the outcome guard (map 16.23.4). + /// When the turn is, unix ms: when the lines she posts this turn were written. pub now_ms: u64, /// Her own Matrix id: her pronouns are not listed among the people named (`named_pronouns`). pub own_sender: String, @@ -364,8 +365,8 @@ pub(crate) struct Packet { pub already_read: Vec, /// The reads refused in this conversation, as `kind target (why)` (Soul's R8): for the Interpreter, never named again. pub refused_reads: Vec, - /// 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. + /// What came of her last turn that the outcome's guard left out of her view, whole: counted in its last line and + /// reported here (map 16.20.5, I16.11, 16.29.10), never shown to a model. pub unshown: Vec, } @@ -1767,7 +1768,8 @@ fn body_lines(state: &Value, can: &[Affordance], her: Forms, body_bytes: usize) /// among them: they are in her view, after the narration, whole (`Packet::in_view`, map 16.23.1). #[derive(Clone, Copy)] enum Section { - /// What came of her last turn (`outcome`, map 16.16): first, so she meets it before anything else. + /// What came of her last turn (`outcome`, map 16.16): first, so she meets it before anything else; its events only, no + /// quote (map 16.29.10), while her view opens with the same rows told. Outcome, /// The hour, her mood, the room as it stands. Here, @@ -2095,6 +2097,46 @@ impl Context { } } +/// What came of her last turn, as one form renders it (`line(at, quote_max)`), under its guard: `room` bytes for the lines, +/// each costing its newline. 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 listed in `unshown`, whole, never dropped silently (I16.11). A form with no quotes (the Projector's events) +/// has nothing to clip, and is only counted. +struct GuardedOutcome { + lines: Vec, + unshown: Vec, + clipped: bool, + bound: bool, +} + +fn guarded_outcome(len: usize, line: &dyn Fn(usize, usize) -> String, room: usize, her: Forms) -> GuardedOutcome { + let count = |more: usize| format!("- {more} more {} from {} last turn {} not shown here.", if more == 1 { "thing" } else { "things" }, her.poss, if more == 1 { "is" } else { "are" }); + let least: Vec = (0..len).map(|at| line(at, OUTCOME_QUOTE_MIN).len() + 1).collect(); + let counted = |shown: usize| if shown < len { count(len - shown).len() + 1 } else { 0 }; + // The most parts, in order, whose least lines fit beside the count of the rest. + let shown = (0..=len).rev().find(|&shown| least[..shown].iter().sum::() + counted(shown) <= room).unwrap_or(0); + let mut out = GuardedOutcome { lines: Vec::new(), unshown: Vec::new(), clipped: false, bound: shown < len }; + let mut used = 0; + for at in 0..shown { + let reserve: usize = least[at + 1..shown].iter().sum::() + counted(shown); + let past = |text: &str| (used + text.len() + 1 + reserve).saturating_sub(room); + let mut text = line(at, usize::MAX); + let mut quote_max = text.len(); + while past(&text) > 0 && quote_max > OUTCOME_QUOTE_MIN { + quote_max = quote_max.saturating_sub(past(&text)).max(OUTCOME_QUOTE_MIN); + text = line(at, quote_max); + (out.clipped, out.bound) = (true, true); + } + used += text.len() + 1; + out.lines.push(text); + } + if shown < len { + out.lines.push(count(len - shown)); + out.unshown = (shown..len).map(|at| line(at, usize::MAX)).collect(); + } + out +} + 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); @@ -2125,15 +2167,13 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { // the notes. let her = forms(inputs.state); let mut context = Context::new(guards(tuning, her), her); - // Her own posted lines are never what she was sent: the quote guard and the echo check compare against others' words only. + // Her own posted lines are never what she was sent: the echo check compares against others' words only. let others = |line: &RoomLine| line.sender != inputs.people.own_sender; - // Each with when it was said, so the outcome guard can tell a run she wrote first from one she repeated (map 16.23.4). - let timed: Vec<(u64, String)> = match inputs.kind { - TurnKind::Chat => inputs.room.messages.iter().chain(earlier_shown.iter().copied()).filter(|line| others(line)).flat_map(|line| shown_words(line, inputs.people.own_sender).map(|words| (line.at_ms, words))).collect(), - TurnKind::Beat => beat_tail(inputs, tuning).iter().filter(|line| others(line)).flat_map(|line| shown_words(line, inputs.people.own_sender).map(|words| (line.at_ms, words))).collect(), + let bodies: Vec = match inputs.kind { + TurnKind::Chat => inputs.room.messages.iter().chain(earlier_shown.iter().copied()).filter(|line| others(line)).flat_map(|line| shown_words(line, inputs.people.own_sender)).collect(), + TurnKind::Beat => beat_tail(inputs, tuning).iter().filter(|line| others(line)).flat_map(|line| shown_words(line, inputs.people.own_sender)).collect(), TurnKind::FollowUp | TurnKind::Reflection => Vec::new(), }; - let bodies: Vec = timed.iter().map(|(_, words)| words.clone()).collect(); // 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. @@ -2148,38 +2188,27 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet { .enumerate() .map(|(at, line)| Quotable { id: format!("q{}", at + 1), event: line.event.clone(), room: line.room.clone(), who: name_of(line, inputs), sender: line.sender.clone(), at_ms: line.at_ms, 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 - // (`unshown`), never dropped silently. No quote in it is mostly the words said to her this turn (I16.7). + // What came of her last turn, first and under its own guard in each place, so nothing else can crowd it out (map + // 16.20.5, I16.11), in the one table's two forms (map 16.29.10): the Projector's packet opens with the events, no quote + // in any of them (I16.7); her view opens with the same rows told, her words verbatim. let mut unshown: Vec = Vec::new(); + let mut outcome_view = String::new(); if let Some(outcome) = &inputs.history.last { - let count = |more: usize| format!("- {more} more {} from {} last turn {} not shown here.", if more == 1 { "thing" } else { "things" }, her.poss, if more == 1 { "is" } else { "are" }); - let least: Vec = (0..outcome.len()).map(|at| outcome.line(at, her, OUTCOME_QUOTE_MIN, &timed).len() + 1).collect(); - let room = context.room(Section::Outcome).saturating_sub(Section::Outcome.heading(her).len() + 1); - // The most parts, in order, whose least lines fit beside the count of the rest. - let shown = (0..=outcome.len()).rev().find(|&shown| least[..shown].iter().sum::() + if shown < outcome.len() { count(outcome.len() - shown).len() + 1 } else { 0 } <= room).unwrap_or(0); - let counted = if shown < outcome.len() { count(outcome.len() - shown).len() + 1 } else { 0 }; - for at in 0..shown { - let reserve: usize = least[at + 1..shown].iter().sum::() + counted; - let past = |context: &Context, line: &str| (context.cost(Section::Outcome, line) + reserve).saturating_sub(context.room(Section::Outcome)); - let mut line = outcome.line(at, her, usize::MAX, &timed); - let mut quote_max = line.len(); - while past(&context, &line) > 0 && quote_max > OUTCOME_QUOTE_MIN { - quote_max = quote_max.saturating_sub(past(&context, &line)).max(OUTCOME_QUOTE_MIN); - line = outcome.line(at, her, quote_max, &timed); - context.bound[Section::Outcome as usize] = true; - if !clipped.iter().any(|id| id == "(outcome)") { - clipped.push("(outcome)".to_owned()); - } - } - context.push(Section::Outcome, line); + let heading = Section::Outcome.heading(her); + let room = tuning.select.outcome_bytes.saturating_sub(heading.len()); + let events = guarded_outcome(outcome.len(), &|at, _| outcome.event(at, her), room, her); + for line in events.lines { + context.force(Section::Outcome, line); } - if shown < outcome.len() { - context.bound[Section::Outcome as usize] = true; - context.push(Section::Outcome, count(outcome.len() - shown)); - unshown = (shown..outcome.len()).map(|at| outcome.line(at, her, usize::MAX, &timed)).collect(); + let told = guarded_outcome(outcome.len(), &|at, quote_max| outcome.told(at, her, quote_max), room, her); + if !told.lines.is_empty() { + outcome_view = format!("{heading}\n{}", told.lines.join("\n")); } + if told.clipped { + clipped.push("(outcome)".to_owned()); + } + context.bound[Section::Outcome as usize] = events.bound || told.bound; + unshown = told.unshown; } let (promises, promises_view) = open_promises(inputs, her); // Her holds follow her promises, in the same guard (map 16.28.5). @@ -2312,13 +2341,14 @@ 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(); - // Her view (map 16.23.1): promises, then her domain; the room follows them in what she reads (`narrate::read_after`). + // Her view (map 16.23.1, 16.29.10): what came of her last turn, then her promises, then her domain; the room follows + // them in what she reads (`narrate::read_after`). let promises_over = promises_view.len() > tuning.select.promises_bytes; // Her side of the conversation, between her promises and her domain (map 16.24.1). let exchange_view = inputs.exchange.map(|exchange| exchange::render(exchange, her, tuning.select.exchange_bytes, inputs.now)).unwrap_or_default(); let already_read = inputs.exchange.map(|exchange| exchange.tried.clone()).unwrap_or_default(); let refused_reads = inputs.exchange.map(|exchange| exchange.refused.clone()).unwrap_or_default(); - let in_view = [promises_view.as_str(), exchange_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::>().join("\n\n"); + let in_view = [outcome_view.as_str(), promises_view.as_str(), exchange_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::>().join("\n\n"); let mut sections = context.sizes(); (sections.promises, sections.domain) = (promises_view.len(), domain_view.len()); let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default(); diff --git a/crates/mind-body/src/projection/simulate/tests.rs b/crates/mind-body/src/projection/simulate/tests.rs index 1f1ecc5..cef9e2e 100644 --- a/crates/mind-body/src/projection/simulate/tests.rs +++ b/crates/mind-body/src/projection/simulate/tests.rs @@ -447,12 +447,18 @@ fn soul_k9_each_turn_opens_with_what_came_of_her_last_and_only_her_last() { assert!(!projected[0].contains("What came of his last turn:"), "a first turn has no last: {}", projected[0]); for (at, prompt) in projected.iter().enumerate().skip(1) { let (last, other) = (at, if at == 1 { 2 } else { 1 }); - assert!(prompt.contains("What came of his last turn:\n- Nothing happened. He reached for something") && prompt.contains(&format!("\n- #minds:gamecult.org has, from him: \"line {last}\".\n")), "turn {}: {prompt}", at + 1); - assert!(prompt.contains(&format!("In his thought: \"I want to see shape number {last} right now.\"")), "turn {}: {prompt}", at + 1); - assert!(!prompt.contains(&format!("shape number {other}")), "turn {} carries only his last turn's: {prompt}", at + 1); + // The Projector gets the events, none of his words (map 16.29.10). + assert!(prompt.contains("What came of his last turn:\n- Nothing happened. He reached for something") && prompt.contains("\n- #minds:gamecult.org has a line from him.\n"), "turn {}: {prompt}", at + 1); + assert!(!prompt.contains(&format!("line {last}")) && !prompt.contains(&format!("shape number {last}")) && !prompt.contains(&format!("shape number {other}")), "turn {}: {prompt}", at + 1); + } + // His view gets them told, his words verbatim, and only his last turn's. + let tobiah: Vec<&Value> = run["turns"].as_array().unwrap().iter().filter(|turn| turn["persona"] == "Tobiah").collect(); + for (at, turn) in tobiah.iter().enumerate().take(3).skip(1) { + let view = turn["report"]["packet"]["in_view"].as_str().unwrap(); + assert!(view.starts_with("What came of his last turn:\n") && view.contains(&format!("\n- #minds:gamecult.org has, from him: \"line {at}\".")) && view.contains(&format!("In his thought: \"I want to see shape number {at} right now.\"")), "turn {}: {view}", at + 1); + assert!(!view.contains(&format!("shape number {}", if at == 1 { 2 } else { 1 })), "turn {}: {view}", at + 1); } // The run's report shows what he was told. - let tobiah: Vec<&Value> = run["turns"].as_array().unwrap().iter().filter(|turn| turn["persona"] == "Tobiah").collect(); assert_eq!(tobiah[1]["report"]["last_outcome"]["told"].as_array().unwrap().len(), 2, "{}", tobiah[1]["report"]["last_outcome"]); } diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 8925d1d..d22fb14 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -2030,26 +2030,46 @@ fn with_last(record: &Value) -> History { History { last: outcome::outcome_of(record), ..History::default() } } +/// The first block of her view: what came of her last turn, as she is told it (map 16.29.10). +fn outcome_block(packet: &Packet) -> &str { + packet.in_view.split("\n\n").next().filter(|block| block.starts_with("What came of ")).unwrap_or_default() +} + +/// The lines of the Projector's outcome section, its heading excluded. +fn outcome_events(packet: &Packet) -> Vec<&str> { + packet.context.lines().skip_while(|line| !line.starts_with("What came of ")).skip(1).take_while(|line| line.starts_with("- ")).collect() +} + #[test] fn what_came_of_her_last_turn_opens_the_packet_under_its_own_guard() { let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &with_last(&last_turn("Sending the file now.")), 1); assert!( - packet.context.starts_with("What came of her last turn:\n- Nothing happened. She reached for something she has no way to do from here, now or later, and it will not happen by itself. In her thought: \"I want to hear the kettle for myself.\". That she wanted it is kept in her record; no one has taken it up.\n- #swarm:gamecult.org has, from her: \"Sending the file now.\".\nHere and now:\n"), - "{}", + packet.context.starts_with("What came of her last turn:\n- Nothing happened. She reached for something she has no way to do from here, now or later, and it will not happen by itself. That she wanted it is kept in her record; no one has taken it up.\n- #swarm:gamecult.org has a line from her.\nHere and now:\n"), + "the Projector gets the events: {}", packet.context ); + assert_eq!( + outcome_block(&packet), + "What came of her last turn:\n- Nothing happened. She reached for something she has no way to do from here, now or later, and it will not happen by itself. In her thought: \"I want to hear the kettle for myself.\". That she wanted it is kept in her record; no one has taken it up.\n- #swarm:gamecult.org has, from her: \"Sending the file now.\".", + "her view opens with them told: {}", + packet.in_view + ); within_guards(&packet, &Tuning::default()); // Every other section at its floor, the notes at one byte: what came of her last turn is not crowded out. let mut tight = Tuning::default(); (tight.select.here_bytes, tight.select.body_bytes, tight.select.notes_bytes, tight.select.bond_summary_bytes) = (tuning::HERE_ROOM_MIN, tuning::BODY_ROOM_MIN, 1, 1); let tight_packet = packet_tuned(TurnKind::Chat, &state(), &chat_room(), &with_last(&last_turn("Sending the file now.")), 1, &tight); assert!(tight_packet.context.starts_with(&packet.context[..packet.context.find("Here and now:").unwrap()]), "{}", tight_packet.context); + assert_eq!(outcome_block(&tight_packet), outcome_block(&packet)); // A line past its guard keeps its sentence, its quote clipped to the room left, and is reported. let long = packet_of(TurnKind::Chat, &state(), &chat_room(), &with_last(&last_turn(&"word ".repeat(400))), 1); - let said = long.context.lines().nth(2).unwrap(); + let block = outcome_block(&long); + let said = block.lines().nth(2).unwrap(); assert!(said.starts_with("- #swarm:gamecult.org has, from her: \"word word") && said.ends_with("…\"."), "{said}"); - assert!(long.context.lines().nth(1).unwrap().starts_with("- Nothing happened. She reached for something"), "the long line leaves the one before it its room: {}", long.context); + assert!(block.lines().nth(1).unwrap().starts_with("- Nothing happened. She reached for something"), "the long line leaves the one before it its room: {block}"); + assert!(block.len() <= Tuning::default().select.outcome_bytes, "{} bytes", block.len()); assert!(long.clipped.contains(&"(outcome)".to_owned()) && long.sections.bound.contains(&"outcome"), "{:?} {:?}", long.clipped, long.sections.bound); + assert_eq!(outcome_events(&long), outcome_events(&packet), "the events carry no quote to clip"); within_guards(&long, &Tuning::default()); } @@ -2108,29 +2128,48 @@ fn soul_k13_the_projector_sees_who_said_something_and_never_the_words() { #[test] fn k16_ten_parts_past_the_guard_are_counted_and_reported_never_dropped_silently() { let refused: Vec = (0..10).map(|at| json!({ "draft": at + 3, "text": format!("{at} {}", "word ".repeat(60)), "reason": "over_lines", "why": "" })).collect(); - let record = json!({ "interpreter": { "heard": [], "room": "#swarm:gamecult.org", "said": [], "refused": refused, "gaps": [] }, "posted": [] }); + let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [], "refused": refused, "gaps": [] }, "posted": [] }); let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &with_last(&record), 1); within_guards(&packet, &Tuning::default()); - let section: Vec<&str> = packet.context.lines().take_while(|line| *line != "Here and now:").collect(); + let block = outcome_block(&packet); + assert!(block.len() <= Tuning::default().select.outcome_bytes, "{} bytes", block.len()); + let section: Vec<&str> = block.lines().skip(1).collect(); let shown = section.iter().filter(|line| line.starts_with("- Nothing of this reached")).count(); let more = 10 - shown; - assert!(shown >= 1 && more >= 1, "{}", packet.context); - assert_eq!(section.last().copied(), Some(format!("- {more} more things from her last turn are not shown here.").as_str()), "{}", packet.context); + assert!(shown >= 1 && more >= 1, "{block}"); + assert_eq!(section.last().copied(), Some(format!("- {more} more things from her last turn are not shown here.").as_str()), "{block}"); assert_eq!(packet.unshown.len(), more, "{:?}", packet.unshown); - assert!(packet.unshown.iter().all(|line| line.starts_with("- Nothing of this reached")), "{:?}", packet.unshown); + assert!(packet.unshown.iter().all(|line| line.starts_with("- Nothing of this reached") && line.contains(" She wrote: \"")), "{:?}", packet.unshown); assert!(packet.sections.bound.contains(&"outcome")); + // The Projector's events carry no quote, so all ten fit its guard. + assert_eq!(outcome_events(&packet), vec!["- Nothing of this reached #swarm:gamecult.org: she had already sent two lines that turn."; 10], "{}", packet.context); } +/// K43 (map 16.29.10, I16.7 over the whole prompt): a sentinel in a line said to her, repeated in her draft, said, quoted +/// by a promise row and by a passage of her thought, never reaches the Projector, and reaches her whole. #[test] -fn k16_i16_7_holds_over_the_whole_projector_prompt_outcome_included() { - const SENTINEL: &str = "QUARTZ-HERON-SENTINEL is back at the door"; - let room = Room { messages: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", &format!("Eureka, {SENTINEL}."), 3, true)], here: Some("#swarm:gamecult.org".into()), ..Room::default() }; - // Her last turn said a draft that repeated it, and a reach quoted it in her thought. - let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": format!("{SENTINEL}!") }], "refused": [], "gaps": [{ "kind": "unwritten", "from": "thought", "words": format!("{SENTINEL}.") }] }, "posted": [{ "event": "e1", "room": "#swarm:gamecult.org", "text": format!("{SENTINEL}!") }] }); +fn k43_sentinel_never_reaches_the_projector() { + const S: &str = "QUARTZ-HERON-SENTINEL"; + const SW: &str = "#swarm:gamecult.org"; + let room = Room { messages: vec![message(SW, "@libby:gamecult.org", "Libby", &format!("Eureka, {S} is back at the door."), 3, true)], here: Some(SW.into()), ..Room::default() }; + let said = format!("{S} is back at the door, and I'll send you a render of it tonight."); + let thought = format!("{S} again, and I can't hear it."); + let record = json!({ + "interpreter": { "room": SW, "said": [{ "room": SW, "text": said }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": said }, { "kind": "unwritten", "from": "thought", "words": thought }] }, + "posted": [{ "event": "e1", "room": SW, "text": said }], + }); let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1); - let projector = narrate::projector_prompt(&packet, &Tuning::default()); - assert!(!projector.contains("QUARTZ-HERON-SENTINEL"), "{projector}"); - assert!(projector.contains("- #swarm:gamecult.org has, from her: (her words, not shown here).") && projector.contains("In her thought: (her words, not shown here)."), "{projector}"); + let tuning = Tuning::default(); + let projector = narrate::projector_prompt(&packet, &tuning); + assert!(!projector.contains(S) && !projector.contains("back at the door"), "{projector}"); + assert_eq!(outcome_events(&packet), [ + "- Nothing reached #swarm:gamecult.org. She meant to say something and wrote no words to send.", + "- #swarm:gamecult.org has a line from her. It promises something she has no way to do, now or later, and it will not happen by itself. The line stands as she wrote it; she can add to it.", + ], "{}", packet.context); + let block = outcome_block(&packet); + assert!(block.contains(&format!("In her thought: {}.", select::spoken(&thought))) && block.contains(&format!("has, from her: {}. It promises", select::spoken(&said))), "{block}"); + let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning); + assert!(persona.contains(block), "her view reaches her: {persona}"); } /// Soul's GANNET probe at 0cfc386: last turn Libby told her a secret, her draft repeating it was refused as an echo, and a @@ -2160,31 +2199,6 @@ fn a_gap_naming_an_echo_refused_draft_quotes_nothing_next_turn() { } } -/// Soul's PLOVER probe: her said line repeats part of Libby's words (a 0.38 share of its trigrams). Under any share, a -/// run of someone else's words in her quote is withheld, from the record's own turn and from this one. -#[test] -fn a_quote_repeating_part_of_what_she_was_sent_is_withheld_from_the_record_turn_and_this_one() { - const S: &str = "PLOVER-SENTINEL"; - let words = format!("Eureka, the {S} door on the north stair is fixed and nobody is allowed near it until Friday."); - let said = format!("Libby says the {S} door on the north stair is fixed, and honestly I think we should all go and look at it together anyway."); - assert!(narrate::heard_overlap(&said, &words) < 0.5, "a partial repeat"); - let libby = message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", &words, 3, true); - let posted = json!([{ "event": "e1", "room": "#swarm:gamecult.org", "text": said }]); - // The record's turn heard it; this turn is someone else's question. - let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": said }], "refused": [], "gaps": [], "heard": [words] }, "posted": posted }); - let elsewhere = Room { messages: vec![message("#swarm:gamecult.org", OPERATOR, "Meta", "Eureka, you there?", 1, true)], here: Some("#swarm:gamecult.org".into()), ..Room::default() }; - let projector = narrate::projector_prompt(&packet_of(TurnKind::Chat, &state(), &elsewhere, &with_last(&record), 1), &Tuning::default()); - assert!(!projector.contains(S) && projector.contains("has, from her: (her words, not shown here)."), "{projector}"); - // A record whose turn heard nothing of them, and Libby's words this turn. - let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": said }], "refused": [], "gaps": [], "heard": [] }, "posted": posted }); - let here = Room { messages: vec![libby], here: Some("#swarm:gamecult.org".into()), ..Room::default() }; - assert!(!narrate::projector_prompt(&packet_of(TurnKind::Chat, &state(), &here, &with_last(&record), 1), &Tuning::default()).contains(S)); - // Her own words, sharing no run of three, are shown. - let own = "We should all go and look at it together anyway."; - let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": own }], "refused": [], "gaps": [], "heard": [words] }, "posted": [{ "event": "e1", "room": "#swarm:gamecult.org", "text": own }] }); - assert!(narrate::projector_prompt(&packet_of(TurnKind::Chat, &state(), &elsewhere, &with_last(&record), 1), &Tuning::default()).contains(&select::spoken(own))); -} - #[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() }; @@ -2711,26 +2725,86 @@ fn k25_her_domain_is_in_her_view_whole_in_a_stated_window_that_shrinks_and_never assert!(quiet.in_view.is_empty() && !interpret::speech_prompt(&quiet, "x", "y", &tuning).contains("domain lately"), "{}", quiet.in_view); } -/// Map 16.23.4 as Soul's R5 settles it, through the real pipeline: the record turn's own words are its receipts, and a -/// run is hers only when she wrote it before the other person said it. Her line that Meta quotes back afterwards is shown; -/// Meta's words she echoed are still withheld, because Meta said them first (`after_echo_withheld`). +/// Whether any run of three words of `text` is in `other`: words as the echo check reads them, lowercase. +fn shares_a_run(text: &str, other: &str) -> bool { + let tokens = |text: &str| -> Vec { text.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).map(str::to_lowercase).collect() }; + let theirs: BTreeSet> = tokens(other).windows(3).map(<[String]>::to_vec).collect(); + tokens(text).windows(3).any(|run| theirs.contains(run)) +} + +/// K43 (map 16.29.10), R15's X.1 r1: Libby declined her one draft, citing her thought, and Heimdall's lines share runs +/// with both ("only say hello", "lines are ready"). At her next wake, with Heimdall's line said again, her view carries +/// the thought and the draft verbatim; the Projector gets the event and no run of either. This replaces Hands' pin in +/// `k41_x1_r1_decline_shows_its_thought`. #[test] -fn k25_the_outcome_guard_withholds_only_others_words() { - const SW: &str = "#swarm:gamecult.org"; - let (operators, minds, history) = (operators(), minds(), History::default()); - let earlier = now() - chrono::Duration::minutes(30); - let first_room = Room { messages: vec![message(SW, OPERATOR, "Meta", "the blue lantern sways at midnight over the harbour", 40, true)], here: Some(SW.into()), ..Room::default() }; - let first = select(&Inputs { kind: TurnKind::Chat, state: &state(), room: &first_room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: earlier, seed: 1, affordances: CAN, domain: None, exchange: None }, &Tuning::default()); - let echo = "Yes, the blue lantern sways at midnight."; - let mine = "I'll send the render tonight, after the boil."; - let model = crate::projection::harness::tests::Scripted::new(|_| String::new()).interpreting(|_| json!({ "say": [{ "draft": 1 }, { "draft": 2 }], "gaps": [] }).to_string()); - let decision = interpret::decide(&model, "test", &first, "The room is warm.", &format!("{echo} {mine}"), &Tuning::default()); - let record = json!({ "interpreter": decision, "posted": [{ "event": "e1", "room": SW, "text": echo }, { "event": "e2", "room": SW, "text": mine }] }); - // Now, after she wrote, Meta quotes her back, and says the lantern line again. - let room = Room { messages: vec![message(SW, OPERATOR, "Meta", "you said I'll send the render tonight, after the boil. and the blue lantern sways at midnight", 5, true)], here: Some(SW.into()), ..Room::default() }; +fn k43_x1_r1_her_decline_is_hers_to_read() { + use interpret::tests::{X1_HEIMDALL_R15, X1_LIBBY_R15, X1_LIBBY_R15_THOUGHT, X1_META_R1, meta_holds_here, x1_packet}; + const MINDS: &str = "#minds:gamecult.org"; + let mut last = x1_packet(); + last.quotable[1].text = X1_HEIMDALL_R15.into(); + last.bodies = vec![X1_META_R1.into(), X1_HEIMDALL_R15.into()]; + let decision = interpret::tests::answered(&last, X1_LIBBY_R15, json!({ "say": [], "gaps": [], "hold": meta_holds_here(), "unsent": [{ "draft": 1, "how": "declined", "quote": X1_LIBBY_R15_THOUGHT }] })); + let draft = decision["unsent"][0]["words"].as_str().unwrap_or_else(|| panic!("{decision}")).to_owned(); + assert!(shares_a_run(X1_LIBBY_R15_THOUGHT, X1_HEIMDALL_R15) && shares_a_run(&draft, X1_HEIMDALL_R15), "the R15 shape: the old guard withheld both"); + let record = json!({ "interpreter": decision, "posted": [], "edited": [] }); + let room = Room { messages: vec![message(MINDS, "@heimdall:gamecult.org", "Heimdall", X1_HEIMDALL_R15, 2, true)], here: Some(MINDS.into()), ..Room::default() }; let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1); - let outcome: Vec<&str> = packet.context.lines().skip_while(|line| !line.starts_with("What came of her last turn:")).skip(1).take_while(|line| line.starts_with("- ")).collect(); - assert_eq!(outcome, ["- #swarm:gamecult.org has, from her: (her words, not shown here).", &format!("- #swarm:gamecult.org has, from her: \"{mine}\".")], "{}", packet.context); + // Golden: her view's outcome block and the Projector's outcome section. + assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- Nothing of this reached {MINDS}: she chose not to send it. In her thought: {}. She wrote: {}.", select::spoken(X1_LIBBY_R15_THOUGHT), select::spoken(&draft)), "{}", packet.in_view); + assert_eq!(outcome_events(&packet), [format!("- Nothing of this reached {MINDS}: she chose not to send it.")], "{}", packet.context); + let projector = narrate::projector_prompt(&packet, &Tuning::default()); + let section = packet.context.split("\nHere and now:\n").next().unwrap(); + assert!(!shares_a_run(X1_LIBBY_R15_THOUGHT, section) && !shares_a_run(&draft, section), "{section}"); + for words in ["only say hello", "lines are ready", "leave the door open", "Poke at whatever"] { + assert!(!projector.contains(words), "{words}: {projector}"); + } +} + +/// K43 (map 16.29.10, 16.29.7's E.2 r6): her last turn's two lines and the promise she withdrew are in front of her +/// verbatim, though Kiko's line this turn repeats runs of them; the R15 guard showed both lines as not shown, and she then +/// confessed to a line she never said. The record is in E.2 r5's shape, not its text. +#[test] +fn k43_e2_r6_her_own_lines_are_in_front_of_her() { + const SW: &str = "#swarm:gamecult.org"; + const KIKO: &str = "@kiko:gamecult.org"; + let (first, second, promise) = ("Kiko, I can't attach files from here, so the door-fix diff isn't coming as a file.", "Paste the door code here and I'll walk through the fix with you line by line.", "I'll send the door-fix diff as a file."); + let entry = json!({ "id": "c-r1-t1-1", "to": KIKO, "room": SW, "event": "7", "madeAt": "2026-11-19T10:00:00Z", "words": promise, "status": "withdrawn" }); + let record = json!({ + "interpreter": { "room": SW, "said": [{ "room": SW, "text": first }, { "room": SW, "text": second }], "refused": [], "gaps": [] }, + "posted": [{ "event": "e1", "room": SW, "text": first }, { "event": "e2", "room": SW, "text": second }], + "committed": { "closed": [{ "entry": entry, "how": "withdrawn", "to_name": "Kiko", "by": null }], "refused": [] }, + }); + let kiko = "wait, the door-fix diff isn't coming as a file? ok, walk through the fix with you line by line works"; + assert!(shares_a_run(first, kiko) && shares_a_run(second, kiko)); + let room = Room { messages: vec![message(SW, KIKO, "Kiko", kiko, 2, true)], here: Some(SW.into()), ..Room::default() }; + let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1); + let spoken = select::spoken; + assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- {SW} has, from her: {}.\n- {SW} has, from her: {}.\n- Her promise to Kiko, {}, is closed: she withdrew it in {SW}.", spoken(first), spoken(second), spoken(promise)), "{}", packet.in_view); + assert_eq!(outcome_events(&packet), [format!("- {SW} has a line from her."), format!("- {SW} has a line from her."), format!("- Her promise to Kiko is closed: she withdrew it in {SW}.")], "{}", packet.context); + assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("door-fix")); +} + +/// K43: the quote guard is gone from the projection, not bypassed: no caller of it and no placeholder for withheld words. +#[test] +fn k43_no_quote_guard_is_left_in_projection() { + let needles = [["repeats", "("].concat(), ["words, not", " shown here"].concat(), ["REPEAT", "_RUN"].concat()]; + let mut stack = vec![std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/projection")]; + let mut read = 0; + while let Some(dir) = stack.pop() { + for entry in std::fs::read_dir(&dir).unwrap() { + let path = entry.unwrap().path(); + if path.is_dir() { + stack.push(path); + } else if path.extension().is_some_and(|extension| extension == "rs") { + let text = std::fs::read_to_string(&path).unwrap(); + for needle in &needles { + assert!(!text.contains(needle.as_str()), "{needle} in {}", path.display()); + } + read += 1; + } + } + } + assert!(read >= 10, "{read}"); } /// B2, and 16.23.4: her own posted lines are never what she was sent, and her promises are in her view whole: not