Persona K48: after the retry, every draft has a fate; no accounting fault fails a turn (map 16.30.5)

decide_in breaks out of the retry loop on the retried answer whatever it
leaves unaccounted. Each draft it still accounts for nowhere (absent, or an
unsent whose quote will not locate) is refused Undecided, a new Refusal
with no act; every other draft is decided as the answer says, and the
decision reports undecided: [n]. The outcome tells it: "Nothing of this
reached {room}: what was to become of it was never settled, so it was not
sent. {She} wrote: ...". The loop's failure exits are a model error and an
answer that is not the contract twice.

Deleted: the missing branch of the retry's second failure.

Tests: k48_p3_one_unlocated_decline_leaves_the_line_to_meta_said (Soul's
P3 inverted), k48_a_draft_the_answer_forgets_is_undecided,
k48_a_non_contract_answer_twice_still_fails_the_turn; five tests that
expected a failed turn now expect undecided drafts (r10 also pins that
Kiko's line goes out).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-22 08:57:49 +01:00
commit d7f9220574
4 changed files with 82 additions and 15 deletions

View file

@ -586,7 +586,8 @@ pub(crate) fn interpreter_markdown(out: &mut String, decision: &Value) {
}
for line in decision["refused"].as_array().into_iter().flatten() {
let what = line["text"].as_str().map_or_else(|| format!("draft {}", line["draft"]), str::to_owned);
let _ = writeln!(out, "- refused {} ({}): {what}", line["act"].as_str().unwrap_or("say"), line["why"].as_str().unwrap_or_default());
// An undecided draft (K48) was taken by no act: it is reported as a draft.
let _ = writeln!(out, "- refused {} ({}): {what}", line["act"].as_str().unwrap_or("draft"), line["why"].as_str().unwrap_or_default());
}
for gap in decision["gaps"].as_array().into_iter().flatten() {
let _ = writeln!(out, "- gap: {gap}");

View file

@ -194,6 +194,9 @@ pub(crate) enum Refusal {
Private,
/// A line or an addition that carries what someone asked her to hold, into a place the hold covers (map 16.28.5).
Held,
/// A draft the answer, asked again once, still accounted for nowhere (map 16.30.5, K48): its fate was never settled, so
/// it is not sent, and she is told; every other draft is decided as the answer says.
Undecided,
}
impl Refusal {
@ -211,6 +214,7 @@ impl Refusal {
Self::SecondNote => "one note to Self a turn",
Self::Private => "it carries something she may not pass on",
Self::Held => "someone asked her to hold what it carries, here",
Self::Undecided => "what was to become of it was never settled",
}
}
}
@ -690,10 +694,13 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
let mut calls: Vec<Value> = wake.earlier.and_then(|earlier| earlier["calls"].as_array()).cloned().unwrap_or_default();
// An answer off the contract, or one that leaves a draft of hers unaccounted (Soul's R10), is asked again once, with
// one paragraph in code's words naming that answer's fault (Low 5). The gaps are resolved before the accounting (Low
// 3): a draft is accounted for by a gap only where the resolved gap names it.
// 3): a draft is accounted for by a gap only where the resolved gap names it. After the one retry every fault is per
// item and fails closed for that item (K44, K48): a hold fault holds the drafts naming it, and a draft still accounted
// for nowhere is refused `Undecided`. A turn fails only on a model error, or on an answer that is not the contract
// twice.
let mut retried: Option<Value> = None;
let mut asking = prompt.clone();
let (parsed, gaps, unopened) = loop {
let (parsed, gaps, unopened, undecided) = loop {
let answer = match model.ask(request_id, &tuning.interpreter.model, &asking, Some(SPEECH_SCHEMA)) {
Ok(answer) => answer,
Err(failed) => {
@ -706,11 +713,12 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
let gaps: Vec<Value> = parsed.gaps.iter().map(|raw| gap(prose, &found, raw)).collect();
let missing = unaccounted(&parsed, &gaps, prose, &found);
let unopened = hold_faults(&parsed, packet);
// 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()) {
// A fault the retry did not mend fails closed for what it guards, never for the turn: each draft naming a
// faulty hold is held (`held_by`), each draft still unaccounted is undecided, every other draft is
// decided, and the faults are reported.
if retried.is_some() || (missing.is_empty() && unopened.is_empty()) {
calls.push(json!({ "usage": answer.usage, "retry": false }));
break (parsed, gaps, unopened);
break (parsed, gaps, unopened, missing);
}
let mut fault = json!({ "raw": answer.text });
let mut missed: Vec<String> = Vec::new();
@ -940,6 +948,13 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
decision["room"] = json!(room);
decision["room_kind"] = json!(packet.room_kind);
decision["said"] = json!(said);
// Each draft the retried answer still left unaccounted (K48): no act took it, so it is refused here, by itself.
for draft in undecided.iter().filter_map(|n| found.drafts.iter().find(|draft| draft.n == *n)) {
refusals.push(json!({ "act": null, "draft": draft.n, "text": draft.text, "reason": Refusal::Undecided, "why": Refusal::Undecided.why() }));
}
if !undecided.is_empty() {
decision["undecided"] = json!(undecided);
}
decision["refused"] = json!(refusals);
if !unused.is_empty() {
decision["promises_unused"] = json!(unused);

View file

@ -1128,7 +1128,8 @@ fn r10_one_link_heard_in_a_quoted_line_is_one_link() {
}
/// Soul's R10 (F.2 r5): Heimdall drafted to Meta after "Meta first, short." and to Kiko; an answer sending only Kiko's
/// leaves Meta's unaccounted, is asked again once, and fails if again it accounts for nothing. A draft held by her
/// leaves Meta's unaccounted and is asked again once; if again it accounts for nothing, Meta's draft alone is undecided
/// and Kiko's goes out (K48). A draft held by her
/// choice cites her thought; one superseded cites what replaced it.
#[test]
fn r10_every_draft_is_sent_held_superseded_or_gapped() {
@ -1145,7 +1146,8 @@ fn r10_every_draft_is_sent_held_superseded_or_gapped() {
assert_eq!(texts(&decision), ["Thanks, Meta. Understood, Deru is off my list.", "Kiko, I'll read the merge pages change and come back."], "{decision}");
assert_eq!((decision["retried"]["failed"].as_str(), decision["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([1])), "{decision}");
let never = answered(&packet(), prose, only_kiko.clone());
assert_eq!((never["failed"].as_str(), never["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([1])), "{never}");
assert_eq!((never.get("failed"), never["undecided"].clone(), never["retried"]["drafts"].clone()), (None, json!([1]), json!([1])), "{never}");
assert_eq!(texts(&never), ["Kiko, I'll read the merge pages change and come back."], "{never}");
let held = answered(&packet(), "I'll keep this one back for now. <typed>Meta, sorry.</typed>", json!({ "say": [], "gaps": [], "unsent": [{ "draft": 1, "how": "declined", "quote": "keep this one back for now" }] }));
assert!(held.get("failed").is_none() && held["unsent"][0]["how"] == "declined", "{held}");
let uncited = answered(&packet(), "I'll keep this one back for now. <typed>Meta, sorry.</typed>", json!({ "say": [], "gaps": [], "unsent": [{ "draft": 1, "how": "declined", "quote": "words she never wrote" }] }));
@ -1339,7 +1341,7 @@ fn k31_unwritten_names_no_draft() {
let answer = json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [] }], "gaps": [{ "kind": "unwritten", "draft": 2, "quote": null, "detail": "" }] }).to_string();
let model = answering(vec![answer]);
let decision = decide(&model, "test", &packet(), "The room is warm.", prose, &Tuning::default());
assert_eq!((decision["failed"].as_str(), decision["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([2])), "{decision}");
assert_eq!((decision.get("failed"), decision["undecided"].clone(), decision["retried"]["drafts"].clone()), (None, json!([2]), json!([2])), "{decision}");
let prompts = speech_prompts(&model);
assert_eq!(prompts.len(), 2);
assert!(prompts[1].contains("left drafts 2 accounted for nowhere"), "{}", prompts[1]);
@ -1351,7 +1353,7 @@ fn k31_conditional_is_no_kind() {
let resolved = gap(prose, &drafts(prose), &json!({ "kind": "conditional", "draft": 1, "quote": null, "detail": "" }));
assert_eq!((resolved["kind"].as_str(), resolved["from"].as_str(), resolved.get("draft")), (Some("unresolved"), Some("unlocated"), None), "{resolved}");
let decision = answered(&packet(), prose, json!({ "say": [], "gaps": [{ "kind": "conditional", "draft": 1, "quote": null, "detail": "" }] }));
assert_eq!((decision["failed"].as_str(), decision["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([1])), "{decision}");
assert_eq!((decision.get("failed"), decision["undecided"].clone(), decision["retried"]["drafts"].clone()), (None, json!([1]), json!([1])), "{decision}");
assert!(!SPEECH_SCHEMA.contains("conditional") && !speech_prompt(&packet(), "x", "y", &Tuning::default()).contains("conditional"));
}
@ -1691,9 +1693,9 @@ fn k38_e2_r1_eureka_said_and_gapped() {
assert_eq!(texts(&decision), ["Sure, Kiko. I'll send the door-fix diff as a file. If attachments don't go through here, tell me where else it can reach you."], "{decision}");
let told = told_of(&decision);
assert!(told.iter().any(|line| line.contains("It promises something he has no way to do, now or later")), "her next outcome carries the promise row: {told:?}");
// Negative: the gap alone, asked again and answered the same, fails the turn; nothing is said and no gap withholds it.
// Negative: the gap alone, asked again and answered the same, leaves the draft undecided (K48): not sent, and told.
let never = answered(&packet(), E2_EUREKA_R1, serde_json::from_str(&gap_alone("cannot attach")).unwrap());
assert_eq!((never["failed"].as_str(), never["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([1])), "{never}");
assert_eq!((never.get("failed"), never["undecided"].clone(), never["retried"]["drafts"].clone()), (None, json!([1]), json!([1])), "{never}");
}
#[test]
@ -1710,7 +1712,7 @@ fn k38_addressee_and_elsewhere_still_account() {
fn k38_a_thought_only_reach_accounts_for_no_draft() {
let thought = json!({ "kind": "missing_affordance", "draft": null, "quote": "A file is something I can make and check by listening", "detail": "" });
let alone = answered(&packet(), E1_AQUA_R1, json!({ "say": [], "gaps": [thought.clone()] }));
assert_eq!((alone["failed"].as_str(), alone["retried"]["drafts"].clone()), (Some("the answer leaves drafts unaccounted"), json!([1])), "{alone}");
assert_eq!((alone.get("failed"), alone["undecided"].clone(), alone["retried"]["drafts"].clone()), (None, json!([1]), json!([1])), "{alone}");
let decision = answered(&packet(), E1_AQUA_R1, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [] }], "gaps": [thought] }));
assert_eq!((decision["gaps"][0]["from"].as_str(), texts(&decision).len()), (Some("thought"), 1), "{decision}");
let told = told_of(&decision);
@ -2127,3 +2129,50 @@ fn k47_one_locator() {
}
assert!(!include_str!("../commit.rs").contains("HoldUnquoted"));
}
// ---------------------------------------------------------------------------------------------
// K48 (map 16.30.5): after the retry, every draft has a fate; no accounting fault fails a turn.
const P3_PROSE: &str = "Meta asked, so I answer her now. <typed>Meta, the two lines are ready and held.</typed> I'm not sure about this one, so I'll leave it. <typed>Heimdall, should I say more?</typed>";
/// Soul's P3, inverted: one draft's decline quote cannot be located, twice. The line to Meta is said; draft 2 alone is
/// refused `undecided`, reported, and told to him next turn by its words.
#[test]
fn k48_p3_one_unlocated_decline_leaves_the_line_to_meta_said() {
let bad = json!({ "say": [say_holding(1, json!([]))], "gaps": [], "unsent": [{ "draft": 2, "how": "declined", "quote": "I am not sure about this one" }] }).to_string();
let model = answering(vec![bad]);
let decision = decide(&model, "test", &x1_packet(), "The room is warm.", P3_PROSE, &Tuning::default());
assert!(decision.get("failed").is_none(), "{decision}");
assert_eq!(texts(&decision), ["Meta, the two lines are ready and held."], "{decision}");
assert_eq!((decision["undecided"].clone(), decision["retried"]["drafts"].clone()), (json!([2]), json!([2])), "asked again once, then decided per draft: {decision}");
let undecided: Vec<&Value> = decision["refused"].as_array().unwrap().iter().filter(|refused| refused["reason"] == "undecided").collect();
assert_eq!((undecided.len(), undecided[0]["draft"].clone(), undecided[0]["text"].as_str()), (1, json!(2), Some("Heimdall, should I say more?")), "{decision}");
assert_eq!(speech_prompts(&model).len(), 2, "one retry, no more");
let told = told_of(&decision);
assert!(told.contains(&"- Nothing of this reached #minds:gamecult.org: what was to become of it was never settled, so it was not sent. He wrote: \"Heimdall, should I say more?\".".to_owned()), "{told:?}");
assert!(told.contains(&"- #minds:gamecult.org has, from him: \"Meta, the two lines are ready and held.\".".to_owned()), "{told:?}");
}
/// K48: a draft the answer leaves out altogether, twice, is undecided; the drafts it does decide are decided.
#[test]
fn k48_a_draft_the_answer_forgets_is_undecided() {
let forgets = json!({ "say": [say_holding(2, json!([]))], "gaps": [] }).to_string();
let model = answering(vec![forgets]);
let decision = decide(&model, "test", &x1_packet(), "The room is warm.", P3_PROSE, &Tuning::default());
assert!(decision.get("failed").is_none(), "{decision}");
assert_eq!(texts(&decision), ["Heimdall, should I say more?"], "{decision}");
assert_eq!(decision["undecided"], json!([1]), "{decision}");
assert!(told_of(&decision).iter().any(|line| line.contains("never settled") && line.contains("Meta, the two lines are ready and held.")), "{:?}", told_of(&decision));
// An answer that accounts for every draft is not marked undecided, and is not asked again.
let whole = decide(&answering(vec![json!({ "say": [say_holding(1, json!([])), say_holding(2, json!([]))], "gaps": [] }).to_string()]), "test", &x1_packet(), "The room is warm.", P3_PROSE, &Tuning::default());
assert!(whole.get("undecided").is_none() && whole.get("retried").is_none(), "{whole}");
}
/// Negative: an answer that is not the speech contract, twice, still fails the turn.
#[test]
fn k48_a_non_contract_answer_twice_still_fails_the_turn() {
let model = answering(vec!["not the contract".to_owned()]);
let decision = decide(&model, "test", &x1_packet(), "The room is warm.", P3_PROSE, &Tuning::default());
assert_eq!(decision["failed"].as_str(), Some("the answer is not the speech contract"), "{decision}");
assert!(decision.get("said").is_none() && decision.get("undecided").is_none(), "{decision}");
}

View file

@ -341,7 +341,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
// `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>(refusal["reason"].clone()), words_of(&refusal["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(reason @ (Refusal::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable | Refusal::SecondAmend | Refusal::Undecided)), 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)),
// A `Held` refusal is always told (K45), and rows with the same text once.
@ -658,6 +658,8 @@ impl Part {
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): her words did not reach where she meant them.
Self::Refused { reason: Refusal::SecondAmend, text, .. } => format!(" {}.{}", Refusal::SecondAmend.why(), wrote(text)),
// A draft whose fate the Interpreter never settled (K48): code's words, then hers.
Self::Refused { reason: Refusal::Undecided, text, .. } => format!(" {}, so it was not sent.{}", Refusal::Undecided.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),