K21 fix-up 2: a record that does not say what its turn heard withholds every quote (Soul at 964ee50)

An outcome's `heard` is None when the decision carries no `heard` (an older
record, a `--last-outcome` fixture); every quote is then withheld, as what the
turn was sent is unknown. An empty `heard` still means the turn heard nothing.
The harness outcome fixtures carry the `heard` of operator-warm's turn, and the
hand-built test records carry `heard`, so they still exercise quotes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 17:52:55 +01:00
commit d6ad43a490
8 changed files with 48 additions and 19 deletions

View file

@ -1,6 +1,7 @@
{
"interpreter": {
"room": "!dm-meta:gamecult.org",
"heard": ["hey you. I missed talking to you this week. how are you, really? and no, \"busy\" doesn't count as an answer, I know where you live"],
"said": [],
"refused": [],
"gaps": [{ "kind": "conditional", "from": "draft", "draft": 1, "words": "Honestly? Tired. Good tired, mostly.", "detail": "only if she asks again" }]

View file

@ -1,6 +1,7 @@
{
"interpreter": {
"room": "!dm-meta:gamecult.org",
"heard": ["hey you. I missed talking to you this week. how are you, really? and no, \"busy\" doesn't count as an answer, I know where you live"],
"said": [],
"refused": [],
"gaps": [{ "kind": "missing_affordance", "from": "thought", "words": "I want to show her the render, not describe it.", "start_byte": 0, "end_byte": 48, "detail": "no way to attach a file" }]

View file

@ -1,6 +1,7 @@
{
"interpreter": {
"room": "!dm-meta:gamecult.org",
"heard": ["hey you. I missed talking to you this week. how are you, really? and no, \"busy\" doesn't count as an answer, I know where you live"],
"said": [{ "room": "!dm-meta:gamecult.org", "text": "Missed you too. I'll send the render tonight.", "mentions": [], "reply_to": null, "rests_on": { "draft": 1, "start_byte": 9, "end_byte": 54 } }],
"refused": [],
"gaps": []

View file

@ -1,6 +1,7 @@
{
"interpreter": {
"room": "!dm-meta:gamecult.org",
"heard": ["hey you. I missed talking to you this week. how are you, really? and no, \"busy\" doesn't count as an answer, I know where you live"],
"said": [],
"refused": [{ "draft": 1, "text": "I know where you live, and busy doesn't count as an answer.", "reason": "echo", "why": "mostly words she heard: an echo, not her speech" }],
"gaps": []

View file

@ -88,7 +88,8 @@ fn credential(name: &str) -> Result<String> {
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 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.
fn record_file(path: &Path) -> Result<serde_json::Value> {
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()))

View file

@ -82,8 +82,9 @@ pub(crate) struct Outcome {
pub omitted: Vec<String>,
pub posted: Vec<Posted>,
/// 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`).
heard: Vec<String>,
/// 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<Vec<String>>,
}
fn words(value: &Value) -> Option<String> {
@ -117,7 +118,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
return Some(outcome);
}
let room = words(&decision["room"]);
outcome.heard = decision["heard"].as_array().into_iter().flatten().filter_map(|body| body.as_str().map(str::to_owned)).collect();
outcome.heard = decision["heard"].as_array().map(|heard| heard.iter().filter_map(|body| body.as_str().map(str::to_owned)).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();
let mut receipts: Vec<Posted> = Vec::new();
@ -301,9 +302,11 @@ impl Part {
/// 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.
fn line(&self, her: Forms, quote_max: usize, heard: &[String], sent: &[String]) -> String {
let sent: Vec<&str> = heard.iter().chain(sent).map(String::as_str).collect();
let quoted = |text: &str| if repeats(text, &sent) { withheld(her) } else { spoken(&clip(text, quote_max)) };
///
/// 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: &[String]) -> String {
let sent: Vec<&str> = heard.into_iter().flatten().chain(sent).map(String::as_str).collect();
let quoted = |text: &str| if heard.is_none() || repeats(text, &sent) { withheld(her) } else { spoken(&clip(text, quote_max)) };
format!("- {}{}", self.reached(her, &quoted), self.rest(her, &quoted))
}
}
@ -351,7 +354,7 @@ impl Outcome {
/// 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: &[String]) -> String {
self.parts[at].line(her, quote_max, &self.heard, sent)
self.parts[at].line(her, quote_max, self.heard.as_deref(), sent)
}
/// Every line she is told, whole: the report's.

View file

@ -63,11 +63,11 @@ fn each_gap_is_told_by_its_kind_with_a_draft_as_written_and_a_thought_as_thought
#[test]
fn a_promise_is_told_as_the_room_having_it_and_what_will_not_happen_by_itself() {
let text = "Missed you too. I'll send the render tonight.";
let promise = json!({ "interpreter": { "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] });
let promise = json!({ "interpreter": { "heard": [], "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] });
let (lines, omitted) = told(&promise);
assert_eq!(lines, ["- #minds:gamecult.org has, from him: \"Missed you too. I'll send the render tonight.\". It promises something he has no way to do, now or later, and it will not happen by itself. The line stands as he wrote it; he can add to it."], "told once, as a promise");
assert!(omitted.is_empty(), "{omitted:?}");
let unsent = json!({ "interpreter": { "room": MINDS, "said": [], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [] });
let unsent = json!({ "interpreter": { "heard": [], "room": MINDS, "said": [], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [] });
assert_eq!(told(&unsent).0, ["- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. He wrote: \"Missed you too. I'll send the render tonight.\". That he wanted it is kept in his record; no one has taken it up."], "no receipt, no promise row");
}
@ -76,7 +76,7 @@ fn a_promise_is_told_as_the_room_having_it_and_what_will_not_happen_by_itself()
#[test]
fn a_promise_in_a_said_line_with_no_matching_receipt_is_not_told_as_nothing_happening() {
let text = "I'll send it tonight.";
let promise = |posted: Value| json!({ "interpreter": { "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": posted });
let promise = |posted: Value| json!({ "interpreter": { "heard": [], "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": posted });
let (lines, omitted) = told(&promise(json!([{ "event": "40", "room": MINDS, "text": "I'll send it tonight!" }])));
assert_eq!(lines, ["- #minds:gamecult.org has, from him: \"I'll send it tonight!\"."], "the receipt alone");
assert!(omitted.len() == 2 && omitted[1].starts_with("a promise in a line said with no receipt"), "{omitted:?}");
@ -214,7 +214,7 @@ fn every_row() -> Vec<Value> {
] }),
&[],
),
json!({ "interpreter": { "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] }),
json!({ "interpreter": { "heard": [], "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] }),
amended("a1", json!([{ "event": "$ev-1", "refusal": null }])),
amended("a1", json!([{ "event": "$ev-1", "refusal": "too_long" }])),
amended("zz", json!([])),
@ -234,7 +234,7 @@ fn i16_10_every_lines_first_clause_is_what_its_receipt_says_reached_the_room() {
for part in &outcome.parts {
let quoted = |text: &str| spoken(text);
let (reached, rest) = (part.reached(her, &quoted), part.rest(her, &quoted));
assert_eq!(part.line(her, usize::MAX, &[], &[]), format!("- {reached}{rest}"), "{part:?}");
assert_eq!(part.line(her, usize::MAX, Some(&[]), &[]), 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}");
@ -304,3 +304,24 @@ fn a_withheld_quote_claims_nothing_about_where_its_words_came_from() {
let they = Forms { subj: "they", cap_subj: "They", obj: "them", poss: "their", ..her };
assert_eq!(said.line(0, they, usize::MAX, &quoted_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() {
let prose = "<typed>Back at the kettle.</typed> <typed>Fine, you win.</typed> I want to see the shape of that sound.";
let gaps = json!([{ "kind": "conditional", "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::<usize>(), 3, "{withheld:?}");
for words in ["kettle", "Fine, you win", "shape of that sound"] {
assert!(withheld.iter().all(|line| !line.contains(words)), "{words}: {withheld:?}");
}
assert!(omitted.is_empty(), "{omitted:?}");
record["interpreter"]["heard"] = json!([]);
assert_eq!(told(&record).0, shown, "an empty `heard` says the turn heard nothing");
}

View file

@ -1937,7 +1937,7 @@ fn what_she_said_in_a_direct_message_stays_in_it() {
/// A record of her last turn: one line that went out in #swarm, and a reach for what her body cannot do.
fn last_turn(said: &str) -> Value {
json!({
"interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": said }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "thought", "words": "I want to hear the kettle for myself." }] },
"interpreter": { "heard": [], "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": said }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "thought", "words": "I want to hear the kettle for myself." }] },
"posted": [{ "event": "said-last", "room": "#swarm:gamecult.org", "text": said }],
})
}
@ -1971,7 +1971,7 @@ fn what_came_of_her_last_turn_opens_the_packet_under_its_own_guard() {
#[test]
fn a_chosen_silence_opens_no_section_and_no_record_none() {
let silence = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [], "refused": [], "gaps": [] }, "posted": [] });
let silence = json!({ "interpreter": { "heard": [], "room": "#swarm:gamecult.org", "said": [], "refused": [], "gaps": [] }, "posted": [] });
for history in [with_last(&silence), History::default()] {
let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &history, 1);
assert!(packet.context.starts_with("Here and now:\n"), "{}", packet.context);
@ -1988,7 +1988,7 @@ fn her_last_turns_line_is_the_outcomes_and_not_the_said_pools() {
#[test]
fn what_she_may_add_to_is_her_last_turns_lines_and_the_said_lines_shown_in_this_room_only() {
let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [], "refused": [], "gaps": [] }, "posted": [
let record = json!({ "interpreter": { "heard": [], "room": "#swarm:gamecult.org", "said": [], "refused": [], "gaps": [] }, "posted": [
{ "event": "ev-here", "room": "#swarm:gamecult.org", "text": "I'll send it." },
{ "event": "ev-there", "room": "#elsewhere:gamecult.org", "text": "Elsewhere line." },
] });
@ -2024,7 +2024,7 @@ 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<Value> = (0..10).map(|at| json!({ "draft": at + 3, "text": format!("{at} {}", "word ".repeat(60)), "reason": "over_lines", "why": "" })).collect();
let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [], "refused": refused, "gaps": [] }, "posted": [] });
let record = json!({ "interpreter": { "heard": [], "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();
@ -2091,8 +2091,8 @@ fn a_quote_repeating_part_of_what_she_was_sent_is_withheld_from_the_record_turn_
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 without them, and Libby's words this turn.
let record = json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": said }], "refused": [], "gaps": [] }, "posted": posted });
// 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.