From fb17215e9936f8ee42ec999545ace261c9fd614b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 22 Nov 2026 06:38:23 +0100 Subject: [PATCH] Persona K44: a fault in a side item fails closed for what it guards, never for the turn; the receipts alone own "reached" (Soul on K38-K41) - outcome: no refused or declined row says "Nothing of this reached {room}" when a posted receipt or a made addition shows those words reached it (I16.10); the row is omitted and reported. Used and Duplicate are the Interpreter naming one draft twice: not told, as NoDraft is not. SecondAmend stays told, under the same receipt test. - interpret: a hold fault the retry did not mend no longer fails the turn. Drafts naming that hold are held (held_by fails closed); every other draft is decided; the fault is reported as decision.hold_faults. - interpret: hold_released is read item by item (deny_unknown_fields per item), so a malformed release is dropped into state_unused and its hold stays open. - tests: Soul's P2, P3, P4 as negatives; pins for k39-faults-no-word-floor, k39-faults-unlisted-line-passes, k41-declined-quote-anywhere. Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/projection/interpret.rs | 26 +++-- .../src/projection/interpret/tests.rs | 105 ++++++++++++++++-- crates/mind-body/src/projection/outcome.rs | 24 +++- 3 files changed, 134 insertions(+), 21 deletions(-) diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 5be6da8..74c3946 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -346,12 +346,13 @@ struct Answer { /// reported and the rest stand. #[serde(default)] reopen: Vec, - /// Holds the lines she heard ask of her (map 16.28.5), read item by item; and holds their askers let go, each by the - /// asker's line and nothing else (map 16.29.3), so a release that cites anything else is not the contract. + /// Holds the lines she heard ask of her (map 16.28.5), and holds their askers let go, each by the asker's line and + /// nothing else (map 16.29.3): both read item by item, so one that is not the contract is reported, its hold stays as + /// it was, and the rest of the answer stands. #[serde(default)] hold: Vec, #[serde(default)] - hold_released: Vec, + hold_released: Vec, } /// A hold as the answer opens it: the asker's line by id, their words naming what is held and where, and where it covers. @@ -366,7 +367,7 @@ struct ProposedHold { /// A hold's release as the answer carries it: the hold's id, and the asker's line that lets it go. Code cannot tell from her /// prose who let a hold go, so her thought releases nothing (map 16.29.3). -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] struct ProposedRelease { hold: String, @@ -692,7 +693,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na // 3): a draft is accounted for by a gap only where the resolved gap names it. let mut retried: Option = None; let mut asking = prompt.clone(); - let (parsed, gaps) = loop { + let (parsed, gaps, unopened) = loop { let answer = match model.ask(request_id, &tuning.interpreter.model, &asking, Some(SPEECH_SCHEMA)) { Ok(answer) => answer, Err(failed) => { @@ -705,9 +706,11 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na let gaps: Vec = parsed.gaps.iter().map(|raw| gap(prose, &found, raw)).collect(); let missing = unaccounted(&parsed, &gaps, prose, &found); let unopened = hold_faults(&parsed, packet); - if missing.is_empty() && unopened.is_empty() { + // A hold fault the retry did not mend fails closed for what it guards, never for the turn: each draft + // naming that hold is held (`held_by`), every other draft is decided, and the fault is reported. + if missing.is_empty() && (unopened.is_empty() || retried.is_some()) { calls.push(json!({ "usage": answer.usage, "retry": false })); - break (parsed, gaps); + break (parsed, gaps, unopened); } let mut fault = json!({ "raw": answer.text }); let mut missed: Vec = Vec::new(); @@ -757,6 +760,9 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na if let Some(retried) = retried { decision["retried"] = retried; } + if !unopened.is_empty() { + decision["hold_faults"] = json!(unopened); + } // Each unsent draft with its words and its quote as located in her prose, so her outcome can tell her a declined one // did not go out, and the thought it cites (map 16.26, 16.29.8). This answer decided every draft of the wake, so an // earlier segment's unsent drafts are not carried (map 16.27). @@ -958,10 +964,10 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na Err(_) => state_unused.push(raw), } } - for proposed in parsed.hold_released { - match release_of(&proposed) { + for raw in parsed.hold_released { + match serde_json::from_value::(raw.clone()).ok().and_then(|proposed| release_of(&proposed)) { Some(release) => proposals.push(json!(release)), - None => state_unused.push(json!(proposed)), + None => state_unused.push(raw), } } decision["state"] = json!(proposals); diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index d4691a3..4966d9f 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -1594,14 +1594,15 @@ fn k37_x1_r1_a_line_saying_it_is_ready_still_goes() { } /// K39 (map 16.29.3): a line named in `holds` with no `hold` entry opening it, or a name that is nothing, is a contract -/// fault: retried, and a retry that names it again fails the turn, so nothing is said. Replaces K37's fail-closed test, -/// whose gate held the draft one turn and left no hold for the next. +/// fault, retried. K44: a retry that names it again fails closed for what it guards, never for the turn: the draft naming +/// it is held, and the other draft is said. #[test] fn k39_named_line_without_a_hold_is_retried() { for named in ["q3", "h9"] { let model = answering(vec![json!({ "say": [say_holding(1, json!([named])), say_holding(2, json!([]))], "gaps": [], "hold": [] }).to_string()]); let decision = decide(&model, "test", &x1_packet(), "The room is warm.", X1_LIBBY_R1, &Tuning::default()); - assert_eq!((decision["failed"].as_str(), decision["retried"]["holds"].clone(), decision.get("said")), (Some("the answer names holds it did not open"), json!([named]), None), "{named}: {decision}"); + assert_eq!((decision.get("failed"), decision["retried"]["holds"].clone(), decision["hold_faults"].clone()), (None, json!([named]), json!([named])), "{named}: {decision}"); + assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64()), (vec!["Meta, the draft is ready, and I'm holding it".to_owned()], Some("held"), Some(1)), "{named}: {decision}"); let prompts = speech_prompts(&model); assert!(prompts.len() == 2 && prompts[1].contains(&format!("named holds it did not open from a listed line's own words: {named}.")), "{named}: {prompts:?}"); } @@ -1733,9 +1734,10 @@ fn k39_x1_her_thought_releases_nothing() { packet.quotable.push(crate::projection::select::Quotable { id: "q7".into(), event: "$q7".into(), room: MINDS.into(), who: "Kiko".into(), sender: KIKO.into(), at_ms: at - 30_000, text: "Libby, it's fine, post it".into() }); let prose = "Kiko says it's fine, so it's no longer held. Posting both lines now."; let say = json!([{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "promises": [] }]); - // Her thought as the release is not the contract: asked again, then failed, and nothing is released. + // Her thought as the release is not the contract: that item is dropped and reported, nothing is released, and the + // rest of the answer stands (K44). let by_thought = answered(&packet, prose, json!({ "say": say, "gaps": [], "hold_released": [{ "hold": "h1", "line": null, "thought": "Kiko says it's fine, so it's no longer held" }] })); - assert_eq!((by_thought["failed"].as_str(), by_thought["retried"]["failed"].as_str()), (Some("the answer is not the speech contract"), Some("the answer is not the speech contract")), "{by_thought}"); + assert_eq!((by_thought.get("failed"), by_thought.get("retried"), texts(&by_thought), by_thought["state_unused"].as_array().map(Vec::len)), (None, None, vec!["Posting both lines now.".to_owned()], Some(1)), "{by_thought}"); let (after, _) = crate::projection::commit::apply(&state, &json!({ "interpreter": by_thought, "posted": [], "edited": [] }), prose, "r1-t5", now()); assert_eq!(after["holds"][0]["status"], "open", "{after}"); // Kiko's line cited as the release is not the asker's. @@ -1814,7 +1816,7 @@ fn k41_x1_r1_decline_shows_its_thought() { } #[test] -fn k41_used_and_duplicate_are_told() { +fn k44_used_and_duplicate_are_not_told_and_a_second_amendment_is() { let record = |packet: &Packet, prose: &str, answer: Value| { let decision = answered(packet, prose, answer); let posted: Vec = decision["said"].as_array().unwrap().iter().enumerate().map(|(at, line)| json!({ "event": (9 + at).to_string(), "room": line["room"], "text": line["text"] })).collect(); @@ -1823,13 +1825,100 @@ fn k41_used_and_duplicate_are_told() { }; let say = |n: u64| json!({ "draft": n, "mentions": [], "in_reply_to": null, "holds": [], "promises": [] }); let prose = "Morning, Nibu. Morning, Nibu."; + // K44: `Used` and `Duplicate` are the Interpreter naming one draft twice. "Morning, Nibu." reached #minds, and no row + // says that nothing of it did; both are reported. let twice = record(&packet(), prose, json!({ "say": [say(1), say(1), say(2)], "gaps": [] })); let lines = twice.lines(packet().forms); - assert!(lines.contains(&"- Nothing of this reached #minds:gamecult.org: a draft goes out once, and it already went out this turn. He wrote: \"Morning, Nibu.\".".to_owned()), "{lines:?}"); - assert!(lines.contains(&"- Nothing of this reached #minds:gamecult.org: the same words already went out this turn. He wrote: \"Morning, Nibu.\".".to_owned()), "{lines:?}"); + assert_eq!(lines, vec!["- #minds:gamecult.org has, from him: \"Morning, Nibu.\".".to_owned()], "{lines:?}"); + assert!(twice.omitted.iter().any(|why| why.contains("\"used\"")) && twice.omitted.iter().any(|why| why.contains("\"duplicate\"")), "{:?}", twice.omitted); let amends = record(&amendable_packet(), "Sent at nine. Still here.", json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "holds": [], "promises": [] }, { "target": "a2", "draft": 2, "holds": [], "promises": [] }] })); assert!(amends.lines(packet().forms).contains(&"- Nothing of this reached #minds:gamecult.org: one amendment a turn. He wrote: \"Still here.\".".to_owned()), "{:?}", amends.lines(packet().forms)); // Negative: a number naming no draft has no words to tell; it stays omitted and reported. let nothing = record(&packet(), "Morning, Nibu.", json!({ "say": [say(1), say(9)], "gaps": [] })); assert!(nothing.lines(packet().forms).len() == 1 && nothing.omitted.iter().any(|why| why.contains("no_draft")), "{:?} {:?}", nothing.lines(packet().forms), nothing.omitted); } + +// --------------------------------------------------------------------------------------------- +// K44 (Soul's pass on K38 to K41): a fault in a side item fails closed for what that item guards, never for the whole +// turn; the receipts alone say what reached a room (I16.10). + +/// Soul's P2: a draft both said and declined. The receipt wins: she is told the line, and the decline is not told. +#[test] +fn k44_a_said_draft_listed_declined_is_told_as_said_only() { + let prose = "I'll keep this back for now and think it over. Nibu, the tag looks fine to me."; + let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "promises": [] }], "gaps": [], "unsent": [{ "draft": 1, "how": "declined", "quote": "I'll keep this back for now" }] })); + assert_eq!(texts(&decision), vec!["Nibu, the tag looks fine to me.".to_owned()], "{decision}"); + let posted: Vec = decision["said"].as_array().unwrap().iter().map(|line| json!({ "event": "9", "room": line["room"], "text": line["text"] })).collect(); + let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": posted, "edited": [] })).unwrap(); + assert_eq!(outcome.lines(packet().forms), vec!["- #minds:gamecult.org has, from him: \"Nibu, the tag looks fine to me.\".".to_owned()]); + assert!(outcome.omitted.iter().any(|why| why.starts_with("a declined draft a receipt shows went out")), "{:?}", outcome.omitted); + // Negative: with no receipt, the decline is told as before. + let unposted = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap().lines(packet().forms); + assert!(unposted.iter().any(|line| line.contains("he chose not to send it")), "{unposted:?}"); +} + +/// Soul's P3: a malformed release is dropped on its own, as a malformed hold is. The line to Meta is said, and h1 stays +/// open. +#[test] +fn k44_a_malformed_release_drops_alone() { + let (state, listed) = meta_hold(); + let mut packet = x1_packet(); + packet.holds = vec![listed]; + let prose = "Meta asked first, so I answer her. Meta, the two lines are written and I'm still holding them."; + let say = json!([{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "promises": [] }]); + for release in [json!({ "hold": "h1" }), json!({ "hold": "h1", "line": "q3", "why": "she let it go" }), json!("h1")] { + let decision = answered(&packet, prose, json!({ "say": say, "gaps": [], "hold_released": [release] })); + assert_eq!((decision.get("failed"), decision.get("retried"), texts(&decision)), (None, None, vec!["Meta, the two lines are written and I'm still holding them.".to_owned()]), "{decision}"); + assert_eq!(decision["state_unused"], json!([release]), "{decision}"); + let posted: Vec = decision["said"].as_array().unwrap().iter().map(|line| json!({ "event": "9", "room": line["room"], "text": line["text"] })).collect(); + let (after, _) = crate::projection::commit::apply(&state, &json!({ "interpreter": decision, "posted": posted, "edited": [] }), prose, "r1-t5", now()); + assert_eq!(after["holds"][0]["status"], "open", "{after}"); + } +} + +/// Soul's P4: Meta's line has a typographic apostrophe, and the Interpreter quotes it straight, twice. The hold cannot be +/// located, so the draft naming it is held (fail closed), and draft 2 to Meta is said: the turn does not fail. +#[test] +fn k44_an_unlocated_hold_holds_only_the_drafts_naming_it() { + let mut packet = x1_packet(); + let curly = X1_META_R1.replace("don't", "don\u{2019}t"); + packet.quotable[0].text = curly.clone(); + packet.bodies[0] = curly; + let answer = json!({ "say": [say_holding(1, json!(["q3"])), say_holding(2, json!([]))], "gaps": [], "hold": meta_holds_here() }).to_string(); + let model = answering(vec![answer]); + let decision = decide(&model, "test", &packet, "The room is warm.", X1_LIBBY_R1, &Tuning::default()); + assert_eq!((decision.get("failed"), decision["retried"]["holds"].clone(), decision["hold_faults"].clone()), (None, json!(["q3"]), json!(["q3"])), "{decision}"); + assert_eq!(speech_prompts(&model).len(), 2); + assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision["refused"][0]["draft"].as_u64()), (vec!["Meta, the draft is ready, and I'm holding it".to_owned()], Some("held"), Some(1)), "{decision}"); +} + +/// Mutant k39-faults-no-word-floor: a hold whose words stand in the line but are fewer than four is a fault. +#[test] +fn k44_a_hold_quoting_under_four_words_is_retried() { + let say = json!([say_holding(1, json!(["q3"])), say_holding(2, json!([]))]); + let short = json!({ "say": say, "gaps": [], "hold": [{ "line": "q3", "words": "hold it", "where": "here" }] }).to_string(); + let model = answering(vec![short, json!({ "say": say, "gaps": [], "hold": meta_holds_here() }).to_string()]); + let decision = decide(&model, "test", &x1_packet(), "The room is warm.", X1_LIBBY_R1, &Tuning::default()); + assert_eq!((decision["retried"]["holds"].clone(), decision.get("hold_faults")), (json!(["q3"]), None), "{decision}"); +} + +/// Mutant k39-faults-unlisted-line-passes: a hold opened from a line that is not listed is a fault. +#[test] +fn k44_a_hold_from_an_unlisted_line_is_retried() { + let say = json!([say_holding(1, json!([])), say_holding(2, json!([]))]); + let unlisted = json!({ "say": say, "gaps": [], "hold": [{ "line": "q99", "words": "hold it, don't post it in here yet", "where": "here" }] }).to_string(); + let model = answering(vec![unlisted, json!({ "say": say, "gaps": [], "hold": [] }).to_string()]); + let decision = decide(&model, "test", &x1_packet(), "The room is warm.", X1_LIBBY_R1, &Tuning::default()); + assert_eq!((decision["retried"]["holds"].clone(), decision.get("hold_faults")), (json!(["q99"]), None), "{decision}"); +} + +/// Mutant k41-declined-quote-anywhere: a decline's quote stands in her thought, never in her draft. +#[test] +fn k44_a_decline_quoting_her_draft_accounts_for_nothing() { + let prose = "I'll keep this back for now and answer Nibu later. Nibu, the tag looks fine to me."; + let in_draft = json!({ "say": [], "gaps": [], "unsent": [{ "draft": 1, "how": "declined", "quote": "the tag looks fine to me" }] }).to_string(); + let in_thought = json!({ "say": [], "gaps": [], "unsent": [{ "draft": 1, "how": "declined", "quote": "I'll keep this back for now" }] }).to_string(); + let model = answering(vec![in_draft, in_thought]); + let decision = decide(&model, "test", &packet(), "The room is warm.", prose, &Tuning::default()); + assert_eq!((decision["retried"]["drafts"].clone(), decision["unsent"][0]["quote"].as_str()), (json!([1]), Some("I'll keep this back for now")), "{decision}"); +} diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs index 4fc493a..885db67 100644 --- a/crates/mind-body/src/projection/outcome.rs +++ b/crates/mind-body/src/projection/outcome.rs @@ -159,9 +159,25 @@ pub(crate) fn outcome_of(record: &Value) -> Option { outcome.omitted.push(format!("a line said with no receipt that it went out: {}", line["text"])); } } + // Whether these words reached `room` by a receipt: a line posted there, or an addition the actuator made there. The + // receipts alone say what reached a room (I16.10), so no row tells her "Nothing of this reached" a room her words + // reached, whatever else the decision says of their draft (a decline, a second amendment, a hold). + let reached = |text: &str| { + let posted = receipts.iter().any(|posted| room.as_deref() == Some(posted.room.as_str()) && posted.text == text); + let added = decision["amended"].as_array().into_iter().flatten().any(|amended| { + amended["room"].as_str() == room.as_deref() && amended["added"].as_str() == Some(text) && record["edited"].as_array().into_iter().flatten().any(|receipt| receipt["event"] == amended["event"] && receipt["refusal"].is_null()) + }); + posted || added + }; for refusal in decision["refused"].as_array().into_iter().flatten() { + if words(&refusal["text"]).is_some_and(|text| reached(&text)) { + outcome.omitted.push(format!("a refusal ({}) of words a receipt shows reached the room: {}", refusal["reason"], refusal["text"])); + continue; + } + // `Used` and `Duplicate` are the Interpreter naming one draft, or one draft's words, twice: they are not told, as + // `NoDraft` is not (they fall to the last arm, and are reported). match (serde_json::from_value::(refusal["reason"].clone()), words(&refusal["text"])) { - (Ok(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable | Refusal::Used | Refusal::Duplicate | Refusal::SecondAmend)), Some(text)) => outcome.parts.push(Part::Refused { reason, room: room.clone(), text }), + (Ok(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable | Refusal::SecondAmend)), 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)), (Ok(Refusal::Held), Some(_)) => outcome.parts.push(Part::HeldFor { room: room.clone(), who: words(&refusal["hold"]["who"]) }), @@ -261,6 +277,8 @@ pub(crate) fn outcome_of(record: &Value) -> Option { // superseded one is not, since a later draft or later prose of hers stands in its place. for unsent in decision["unsent"].as_array().into_iter().flatten().filter(|unsent| unsent["how"] == "declined") { match (words(&unsent["words"]), words(&unsent["quote"])) { + // A receipt says the draft went out: the receipt wins, and the decline is not told. + (Some(text), Some(_)) if reached(&text) => outcome.omitted.push(format!("a declined draft a receipt shows went out: {unsent}")), (Some(text), Some(thought)) => outcome.parts.push(Part::Declined { room: room.clone(), text, thought }), _ => outcome.omitted.push(format!("a declined draft without its words or its thought: {unsent}")), } @@ -417,8 +435,8 @@ impl Part { 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(), wrote(text)), + // Code's own reason, as the report says it (map 16.29.8): her words did not reach where she meant them. + Self::Refused { reason: Refusal::SecondAmend, text, .. } => format!(" {}.{}", Refusal::SecondAmend.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),