From 22ee30282bc587997d6d7d5ed89dcf082cf5ca86 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 16:58:01 +0100 Subject: [PATCH] K18: the contract's smaller holes (map 16.20.7) - One identity for a draft, its number: `used` keys on the draft number for say, amend and suggest. "The same words go out once" is its own refusal, Duplicate, keyed on text and applied only to say, so two identical drafts are two drafts: the second is refused as Duplicate if said, and may be a note. - A refused act does not use up its draft: a draft enters `used` only when its act succeeds, so an amendment refused as not_amendable (or a line refused as an echo) leaves the draft free for a note; the refusal is told (K16 row). - Every refusal record carries its draft's words (unchanged); the outcome's report names the reason of a refusal she is not told. - ProposedNote.private is Option: an answer that does not say refuses the note as private (fails closed). - The C3c record shape (failed XOR receipts, broke_after, malformed refused and reported) landed in outcome_of with K16, with its tests; the simulator already writes only the two shapes. Verification: two identical drafts (Duplicate on say, a note from the second); a not_amendable amendment's draft then left as a note, and an echo-refused line's draft too; a note answer without `private` is refused as private; the K16 tests for receipts with broke_after and for failed with receipts. Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/interpret.rs | 32 ++++++++++++------- .../src/projection/interpret/tests.rs | 30 ++++++++++++++++- crates/mind-body/src/projection/outcome.rs | 2 +- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index aa8baf9..9c212df 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -156,6 +156,8 @@ pub(crate) enum Refusal { NoDraft, /// The draft already went somewhere this turn. Used, + /// The same words already went out this turn, from another draft: said once (map 16.20.7). + Duplicate, /// Mostly the words she had just heard. Echo, /// Past the lines one turn may say. @@ -175,7 +177,8 @@ impl Refusal { match self { Self::NoRoom => "the turn has no room to speak in", Self::NoDraft => "it names no draft she set down", - Self::Used => "one draft goes one place: its words were already used this turn", + Self::Used => "one draft goes one place: it already went somewhere this turn", + Self::Duplicate => "the same words already went out this turn", Self::Echo => "mostly words she heard: an echo, not her speech", Self::OverLines => "past the lines one turn may say", Self::NotAmendable => "it names no line of hers she may add to here", @@ -309,8 +312,9 @@ struct ProposedNote { draft: Option, #[serde(default)] about: Option, + /// Absent is not "not private": a note whose answer does not say is refused as private (fails closed, map 16.20.7). #[serde(default)] - private: bool, + private: Option, } /// An amendment as the model proposes it: the id of a line she may add to, and the draft that is her addition. @@ -412,9 +416,11 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra let shown = |id: &str| packet.people.iter().any(|(_, person)| person == id); let mut said: Vec = Vec::new(); let mut refusals = Vec::new(); - // One draft goes one place, and the same words go out once: a draft is used by its words, so two identical drafts - // are one. `went` holds the drafts that went somewhere. - let mut used: Vec<&str> = Vec::new(); + // A draft is its number (map 16.20.7): one draft goes one place, and a draft is used only when its act succeeds, so a + // refused act leaves it free. The same words go out once: a said draft whose words already went out is `Duplicate`, + // and only speech is held to that, so two identical drafts may still be a line and a note. `went` holds the drafts + // that went somewhere; `said_drafts` the ones said. + let mut used: Vec = Vec::new(); let mut went: Vec<&Draft> = Vec::new(); let mut said_drafts: Vec = Vec::new(); for line in parsed.say { @@ -424,8 +430,10 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra }; let reason = if room.is_none() { Some(Refusal::NoRoom) - } else if used.contains(&draft.text.as_str()) { + } else if used.contains(&draft.n) { Some(Refusal::Used) + } else if said.iter().any(|line| line["text"] == draft.text.as_str()) { + Some(Refusal::Duplicate) } else if echo(&draft.text, &packet.bodies) { Some(Refusal::Echo) } else if said.len() >= MAX_LINES { @@ -433,7 +441,6 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra } else { None }; - used.push(&draft.text); if let Some(reason) = reason { refusals.push(refused(Act::Say, Some(draft), None, reason)); continue; @@ -444,6 +451,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra Some(id) => (None, Some(id)), None => (None, None), }; + used.push(draft.n); said_drafts.push(draft.n); went.push(draft); said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "reply_to": reply_to, "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown, "reply_to": unknown_reply } })); @@ -457,7 +465,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra continue; }; let target = proposed.target.as_deref().and_then(|id| packet.amendable.iter().find(|line| line.id == id.trim())); - let reason = if used.contains(&draft.text.as_str()) { + let reason = if used.contains(&draft.n) { Some(Refusal::Used) } else if echo(&draft.text, &packet.bodies) { Some(Refusal::Echo) @@ -466,9 +474,9 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra } else { None }; - used.push(&draft.text); match (reason, target) { (None, Some(line)) => { + used.push(draft.n); went.push(draft); amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n })); } @@ -483,16 +491,15 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra refusals.push(refused(Act::Suggest, None, proposed.draft, Refusal::NoDraft)); continue; }; - let reason = if used.contains(&draft.text.as_str()) { + let reason = if used.contains(&draft.n) { Some(Refusal::Used) } else if !suggestions.is_empty() { Some(Refusal::SecondNote) - } else if proposed.private { + } else if proposed.private != Some(false) { Some(Refusal::Private) } else { None }; - used.push(&draft.text); if let Some(reason) = reason { refusals.push(refused(Act::Suggest, Some(draft), None, reason)); continue; @@ -502,6 +509,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra Some(id) => (None, Some(id)), None => (None, None), }; + used.push(draft.n); went.push(draft); suggestions.push(json!({ "kind": proposed.kind, "about": about, "room": room, "text": draft.text, "draft": draft.n, "dropped": { "about": dropped } })); } diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index 4fbca64..5622615 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -513,7 +513,7 @@ fn soul_an_answer_without_say_or_gaps_is_a_failure_not_a_silence() { fn soul_the_same_words_go_out_once_whatever_their_draft_numbers() { let twice = decided("On it. I mean it. On it.", json!([{ "draft": 1 }, { "draft": 2 }])); assert_eq!(texts(&twice), ["On it."], "{twice}"); - assert!(refused_why(&twice).contains("one draft goes one place"), "{twice}"); + assert!(refused_why(&twice).contains("the same words already went out"), "{twice}"); } #[test] @@ -560,3 +560,31 @@ fn k17_a_thought_only_intent_is_a_reach_and_any_other_gap_on_an_acted_draft_is_a let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default()); assert!(prompt.contains("missing_affordance when he means to do something, now or later, that his body cannot do") && prompt.contains("an intent to act is missing_affordance, an intent to say with no draft is unwritten"), "{prompt}"); } + +#[test] +fn k18_two_identical_drafts_are_two_drafts_and_the_second_said_is_a_duplicate() { + let prose = "On it. I mean it. On it."; + let twice = decided(prose, json!([{ "draft": 1 }, { "draft": 2 }])); + assert_eq!((texts(&twice), refusals(&twice)), (vec!["On it.".to_owned()], vec![("say".to_owned(), "duplicate".to_owned())]), "{twice}"); + assert_eq!(twice["refused"][0]["text"], "On it.", "every refusal carries its draft's words"); + let note = answered(&packet(), prose, json!({ "say": [{ "draft": 1 }], "gaps": [], "suggest": [{ "kind": "idea", "draft": 2, "about": null, "private": false }] })); + assert_eq!((texts(¬e), note["suggestions"][0]["text"].as_str(), refusals(¬e)), (vec!["On it.".to_owned()], Some("On it."), vec![]), "the second may still be a note: {note}"); +} + +#[test] +fn k18_a_refused_act_does_not_use_up_its_draft_and_is_told() { + let prose = "I should fix that. Couldn't send it after all."; + let decision = answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "zz", "draft": 1 }], "suggest": [{ "kind": "idea", "draft": 1, "about": null, "private": false }] })); + assert_eq!((refusals(&decision), decision["suggestions"][0]["text"].as_str()), (vec![("amend".to_owned(), "not_amendable".to_owned())], Some("Couldn't send it after all.")), "{decision}"); + let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] })).unwrap().lines(packet().forms); + assert!(told.iter().any(|line| line.starts_with("- Nothing changed, and nothing reached #minds:gamecult.org:")) && told.iter().any(|line| line.starts_with("- He left Self a note:")), "{told:?}"); + // An echo-refused line leaves its draft free for a note too. + let echoed = answered(&packet(), "The economy is still the least-built part!", json!({ "say": [{ "draft": 1 }], "gaps": [], "suggest": [{ "kind": "feedback", "draft": 1, "about": NIBU, "private": false }] })); + assert_eq!((refusals(&echoed), echoed["suggestions"].as_array().unwrap().len()), (vec![("say".to_owned(), "echo".to_owned())], 1), "{echoed}"); +} + +#[test] +fn k18_a_note_whose_answer_does_not_say_private_is_refused_as_private() { + let decision = noted(&packet(), json!([]), json!([{ "kind": "idea", "draft": 1, "about": null }])); + assert_eq!((decision["suggestions"].as_array().unwrap().len(), refusals(&decision)), (0, vec![("suggest".to_owned(), "private".to_owned())]), "fails closed: {decision}"); +} diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs index 4007d6c..ed3ba38 100644 --- a/crates/mind-body/src/projection/outcome.rs +++ b/crates/mind-body/src/projection/outcome.rs @@ -131,7 +131,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option { (Ok(reason @ (Refusal::Echo | Refusal::OverLines)), Some(text)) => outcome.parts.push(Part::Refused { reason, room: room.clone(), text }), (Ok(Refusal::NotAmendable), Some(added)) => outcome.parts.push(Part::NotAmended { refusal: None, room: room.clone(), added }), (Ok(reason @ (Refusal::Private | Refusal::SecondNote)), Some(_)) => outcome.parts.push(Part::NoteRefused(reason)), - _ => outcome.omitted.push(format!("a refusal that is no act of hers: {}", refusal["why"])), + _ => outcome.omitted.push(format!("a refusal she is not told ({}): {}", refusal["reason"], refusal["why"])), } } // An amendment is told by the actuator's receipt (`edited`: `{event, refusal}`), never by the decision alone.