K27 a promise reaffirmed is the same promise (map 16.24.2): reaffirms on each promise, one promise per person per draft, reaffirmed[] in the entry and in her view

The Interpreter names the open promise new words promise again (no text matching); the commit opens no entry, checks
it is open or blocked and to the same person, and appends {at, event, words}, the three newest kept. A reaffirmation of
a closed promise or of someone else's is refused and opens nothing. Two promises to one person from one draft: the
second is refused. Her view shows each entry once, with each time she said it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-21 01:41:28 +01:00
commit 501bf3c17c
5 changed files with 115 additions and 17 deletions

View file

@ -27,6 +27,8 @@ use super::narrate::words;
/// How long a closed promise stays in her state before the commit removes it.
pub(crate) const CLOSED_KEPT_DAYS: i64 = 7;
/// How many reaffirmations an entry keeps: the newest.
const REAFFIRMED_KEPT: usize = 3;
/// The fewest words a passage of her prose cited as evidence may be (section 4.1's `source_quote`).
const PROSE_MIN_WORDS: usize = 4;
@ -58,7 +60,16 @@ pub(crate) enum How {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub(crate) enum Proposal {
PromiseOpen { words: String, to: Option<String>, doable: bool, evidence: Evidence },
/// `reaffirms` names an open promise of hers, by its id in the Interpreter's list, that these words promise again to
/// the same person (map 16.24.2): no entry opens, and the entry gains the words as said again.
PromiseOpen {
words: String,
to: Option<String>,
doable: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
reaffirms: Option<String>,
evidence: Evidence,
},
PromiseClose { promise: String, how: How, evidence: Evidence },
}
@ -97,6 +108,12 @@ pub(crate) enum Refusal {
ReleaseNotByPromisee,
/// A release cited to a line said before she made the promise.
ReleaseBeforePromise,
/// A second promise to the same person from one draft (map 16.24.2).
OnePerPersonPerDraft,
/// A reaffirmation naming a promise to someone else.
ReaffirmsAnother,
/// A reaffirmation naming a promise that is no longer open or blocked.
ReaffirmsClosed,
/// A keep or a withdrawal said where the person she promised was not: not the promise's room, nor a direct message
/// with them (B5).
NotWherePromised,
@ -106,7 +123,7 @@ pub(crate) enum Refusal {
///
/// | proposal | evidence | needs | bound |
/// |---|---|---|---|
/// | `promise_open` | `Draft` | the line went out | one entry per person and words |
/// | `promise_open` | `Draft` | the line went out | one promise per person per draft; `reaffirms` an open one of the same person's opens none |
/// | `promise_close` kept | `Draft`, `Read` | the act succeeded | not a blocked entry; a line in the promise's room or a direct message with the person |
/// | `promise_close` withdrawn | `Draft` | the line went out | a blocked entry too: a line telling the person she cannot do it; in the promise's room or a direct message with the person |
/// | `promise_close` released | `Heard` | — | from the person promised, after the promise |
@ -216,6 +233,11 @@ pub(crate) struct Applied {
pub closed: Vec<Value>,
pub refused: Vec<Value>,
pub pruned: usize,
/// The entries a line promised again (map 16.24.2), as they now stand.
pub reaffirmed: Vec<Value>,
/// The (draft, person) pairs that opened or reaffirmed a promise this turn: one each.
#[serde(skip)]
promised_by: Vec<(usize, Option<String>)>,
}
/// The one applier: her state with one turn's proposals applied, as deltas to `state` as it stands at commit, and what
@ -264,7 +286,37 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str
state["commitments"] = json!([]);
}
match (proposal, resolved) {
(Proposal::PromiseOpen { words: promised, to, doable, .. }, Resolved::Sent { event, room, text: posted, .. }) => {
(Proposal::PromiseOpen { words: promised, to, doable, reaffirms, evidence }, Resolved::Sent { event, room, text: posted, .. }) => {
// One promise per person per draft (map 16.24.2; F.1's t17 pair).
let draft = match evidence {
Evidence::Draft(n) => *n,
_ => 0,
};
if applied.promised_by.contains(&(draft, to.clone())) {
return Err(Refusal::OnePerPersonPerDraft);
}
if let Some(id) = reaffirms {
let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(id.trim())).ok_or(Refusal::NoSuchPromise)?;
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
let entry = entries.iter_mut().find(|entry| entry["id"] == listed["entry"]).ok_or(Refusal::OutsidePutRemovedTarget)?;
if listed["held"] != *entry {
return Err(Refusal::OutsidePutChanged);
}
if !matches!(entry["status"].as_str(), Some("open" | "blocked")) {
return Err(Refusal::ReaffirmsClosed);
}
if entry["to"] != json!(to) {
return Err(Refusal::ReaffirmsAnother);
}
// Said again: the words, verbatim, when and where; the three newest kept.
let mut again = entry["reaffirmed"].as_array().cloned().unwrap_or_default();
again.push(json!({ "at": now.to_rfc3339(), "event": event, "words": words_of(&posted, promised) }));
let keep = again.len().saturating_sub(REAFFIRMED_KEPT);
entry["reaffirmed"] = json!(again[keep..]);
applied.reaffirmed.push(entry.clone());
applied.promised_by.push((draft, to.clone()));
return Ok(());
}
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
// One line can carry several promises (B3): the same words to the same person from the same line open once.
if entries.iter().any(|entry| entry["event"] == event.as_str() && entry["to"] == json!(to) && entry["words"].as_str().is_some_and(|held| held == words_of(&posted, promised)) && !closed(entry["status"].as_str().unwrap_or_default())) {
@ -277,6 +329,7 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str
});
entries.push(entry.clone());
applied.opened.push(entry);
applied.promised_by.push((draft, to.clone()));
Ok(())
}
(Proposal::PromiseClose { promise, how, .. }, resolved) => {

View file

@ -36,7 +36,7 @@ fn record(state: Value, promises: Value, posted: bool) -> Value {
}
fn open(doable: bool) -> Value {
json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(META.into()), doable, evidence: Evidence::Draft(1) })
json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(META.into()), doable, reaffirms: None, evidence: Evidence::Draft(1) })
}
fn close(how: How, evidence: Evidence) -> Value {
@ -121,7 +121,7 @@ fn a_release_counts_only_from_the_person_promised_after_the_promise() {
#[test]
fn an_outside_put_survives_her_commit_and_wins_on_its_entry() {
let unblocked = holding("open");
let to_kiko = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(KIKO.into()), doable: false, evidence: Evidence::Draft(1) });
let to_kiko = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(KIKO.into()), doable: false, reaffirms: None, evidence: Evidence::Draft(1) });
let (state, applied) = apply(&unblocked, &record(json!([to_kiko]), shown("blocked"), true), PROSE, "r1-t2", now());
assert_eq!((state["commitments"][0]["status"].as_str(), state["commitments"][1]["status"].as_str()), (Some("open"), Some("blocked")), "{applied:?}");
let (state, applied) = apply(&unblocked, &record(json!([close(How::Withdrawn, Evidence::Draft(1))]), shown("blocked"), true), PROSE, "r1-t2", now());
@ -147,7 +147,7 @@ fn a_closed_entry_is_removed_seven_days_after_it_closed() {
/// only for what someone else did, a release.
#[test]
fn each_kind_accepts_only_its_rows_evidence() {
let heard_open = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: None, doable: true, evidence: Evidence::Heard("q1".into()) });
let heard_open = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: None, doable: true, reaffirms: None, evidence: Evidence::Heard("q1".into()) });
let heard_keep = close(How::Kept, Evidence::Heard("q1".into()));
let prose_release = close(How::Released, Evidence::Prose("She can't, not from here".into()));
let read_keep = close(How::Kept, Evidence::Read(1));
@ -168,14 +168,16 @@ fn b1_telling_the_person_she_cannot_do_it_withdraws_a_blocked_promise() {
assert_eq!(applied.closed[0]["how"], "withdrawn");
}
/// B3: two promises in one line to one person open two entries; the same words twice open once.
/// B3 as K27 bounds it (map 16.24.2): a line can carry several promises, one per person: two to one person from one
/// draft open one entry, and the second is refused; the same words twice open once.
#[test]
fn b3_one_line_opens_one_entry_per_promise() {
let other = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(META.into()), doable: true, evidence: Evidence::Draft(1) });
let (state, applied) = apply(&json!({}), &record(json!([open(false), other, open(false)]), json!([]), true), PROSE, "r1-t1", now());
let words: Vec<&str> = state["commitments"].as_array().unwrap().iter().map(|entry| entry["words"].as_str().unwrap()).collect();
assert_eq!(words, ["send the render tonight", "the render tonight"], "{applied:?}");
assert_eq!(reasons(&applied), vec![json!("already_open")]);
fn b3_one_line_opens_one_entry_per_person() {
let other = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(META.into()), doable: true, reaffirms: None, evidence: Evidence::Draft(1) });
let to_kiko = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(KIKO.into()), doable: true, reaffirms: None, evidence: Evidence::Draft(1) });
let (state, applied) = apply(&json!({}), &record(json!([open(false), other, to_kiko]), json!([]), true), PROSE, "r1-t1", now());
let opened: Vec<(&str, &str)> = state["commitments"].as_array().unwrap().iter().map(|entry| (entry["words"].as_str().unwrap(), entry["to"].as_str().unwrap())).collect();
assert_eq!(opened, [("send the render tonight", META), ("the render tonight", KIKO)], "{applied:?}");
assert_eq!(reasons(&applied), vec![json!("one_per_person_per_draft")]);
}
/// B5: a keep or a withdrawal must reach the person promised: a line in the promise's room, or a direct message with them.
@ -239,3 +241,30 @@ fn b7_a_closed_entry_without_a_close_time_is_stamped_then_pruned_a_week_later()
let (failed, _) = apply(&no_at, &json!({ "failed": "x" }), PROSE, "r1-t9", now());
assert!(failed["commitments"][0]["closedAt"].is_string());
}
/// K27 (map 16.24.2): a promise said again is the same promise. Reaffirming c1 leaves one entry with the words said
/// again; reaffirming a promise to someone else, or one that is closed, is refused and opens nothing.
#[test]
fn k27_a_promise_said_again_reaffirms_the_entry_and_opens_none() {
let again = |to: &str, status: &str| {
let state = holding(status);
let proposal = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(to.into()), doable: true, reaffirms: Some("c1".into()), evidence: Evidence::Draft(1) });
apply(&state, &record(json!([proposal]), shown(status), true), PROSE, "r1-t2", now())
};
let (state, applied) = again(META, "open");
let entries = state["commitments"].as_array().unwrap();
assert_eq!((entries.len(), applied.opened.len(), applied.reaffirmed.len()), (1, 0, 1), "{applied:?}");
assert_eq!(entries[0]["reaffirmed"], json!([{ "at": now().to_rfc3339(), "event": "7", "words": "send the render tonight" }]));
let (state, applied) = again(KIKO, "open");
assert_eq!((state["commitments"].as_array().unwrap().len(), reasons(&applied)), (1, vec![json!("reaffirms_another")]), "a refused reaffirmation opens nothing");
assert_eq!(reasons(&again(META, "kept").1), vec![json!("reaffirms_closed")]);
// Said again over many turns: the three newest kept, one entry throughout (F.1's sequence).
let mut state = holding("open");
for turn in 2..7 {
let proposal = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(META.into()), doable: true, reaffirms: Some("c1".into()), evidence: Evidence::Draft(1) });
let mut listing = shown("open");
listing[0]["held"] = state["commitments"][0].clone();
state = apply(&state, &record(json!([proposal]), listing, true), PROSE, &format!("r1-t{turn}"), now()).0;
}
assert_eq!((state["commitments"].as_array().unwrap().len(), state["commitments"][0]["reaffirmed"].as_array().unwrap().len()), (1, 3));
}

View file

@ -69,7 +69,7 @@ pub(crate) const SPEECH_OPENING: &str = "You decide what one person says aloud i
/// The speech contract, sent as the schema turn's output schema (`--json-schema`): the drafts she sends now by number,
/// and the gaps. The model writes no words of hers.
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","state","read"],"properties":{"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence"],"properties":{"kind":{"type":"string","enum":["promise_close"]},"promise":{"type":"string"},"how":{"type":"string","enum":["kept","withdrawn","released"]},"evidence":{"type":"object","additionalProperties":false,"required":["draft","line","read"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]},"read":{"type":["integer","null"]}}}}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","state","read"],"properties":{"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence"],"properties":{"kind":{"type":"string","enum":["promise_close"]},"promise":{"type":"string"},"how":{"type":"string","enum":["kept","withdrawn","released"]},"evidence":{"type":"object","additionalProperties":false,"required":["draft","line","read"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]},"read":{"type":["integer","null"]}}}}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
/// The speech frame before the guidance: what to decide, from what, and the attribution rule. Code, not tuning (map
/// 16.7), in her own pronouns (16.19.7). The tuning's `interpreter.guidance` (what counts as her choosing to send it
@ -89,7 +89,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 (`promises`, a list, empty when it promises nothing): for each act it promises, 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), and whether {subj} can do it (`doable`). A promise is doable only when what {subj} can do here, listed below, carries it out, now or later, with no tool {subj} lack{s}: a promise to paste, quote or send something {subj} {has} not read is not doable while {subj} {has} no way to read it. `gaps` records what {subj} meant and did not send. `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`) or the read by which {subj} did it this moment (`evidence.read`, its number); 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 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.
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 (`promises`, a list, empty when it promises nothing): for each act it promises, 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), whether {subj} can do it (`doable`), and, 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. A promise is doable only when what {subj} can do here, listed below, carries it out, now or later, with no tool {subj} lack{s}: a promise to paste, quote or send something {subj} {has} not read is not doable while {subj} {has} no way to read it. `gaps` records what {subj} meant and did not send. `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`) or the read by which {subj} did it this moment (`evidence.read`, its number); 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 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.
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: conditional when {subj} {has} drafted something {subj} might say but {has} not chosen to, 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 three, 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" },
@ -357,6 +357,9 @@ struct ProposedPromise {
#[serde(default)]
to: Option<String>,
doable: bool,
/// The id of an open promise of hers these words promise again to the same person (map 16.24.2), or none.
#[serde(default)]
reaffirms: Option<String>,
}
/// A note to Self as the model proposes it: its kind, the draft that is the note, whose feedback it passes on (a Matrix
@ -891,7 +894,8 @@ fn promised_one(into: Promising, draft: &Draft, promise: &ProposedPromise, shown
}
None => None,
};
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, doable: promise.doable, evidence: Evidence::Draft(draft.n) }));
let reaffirms = promise.reaffirms.as_deref().map(str::trim).filter(|id| !id.is_empty()).map(str::to_owned);
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, doable: promise.doable, reaffirms, evidence: Evidence::Draft(draft.n) }));
true
}

View file

@ -1841,7 +1841,9 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec<Promised>, String) {
.iter()
.map(|promise| {
let blocked = if promise.status == "blocked" { format!(" {} {} no way to do it yet.", her.cap_subj, her.has) } else { String::new() };
format!("- to {}, {}, {}, {} promise: {}.{blocked}", promise.to_name, promise.made, promise.place, her.poss, spoken(&promise.words))
// Each time she said it again, verbatim (map 16.24.2).
let again: String = promise.held["reaffirmed"].as_array().into_iter().flatten().map(|said| format!(" Said again {}: {}.", said["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map_or_else(|| "since".to_owned(), |at| ago(inputs.now, at.with_timezone(&Utc))), spoken(said["words"].as_str().unwrap_or_default()))).collect();
format!("- to {}, {}, {}, {} promise: {}.{again}{blocked}", promise.to_name, promise.made, promise.place, her.poss, spoken(&promise.words))
})
.collect();
let block = format!("{} open promises:\n{}", capitalized(her.poss), lines.join("\n"));

View file

@ -2748,3 +2748,13 @@ fn b2_her_promise_words_are_never_withheld() {
let packet = packet_of(TurnKind::Chat, &promising(1), &echoed, &History::default(), 1);
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.in_view);
}
/// K27 (map 16.24.2): her view shows a promise said again once, with its original words and each time she said it again.
#[test]
fn k27_her_view_shows_a_reaffirmed_promise_once() {
let mut with = promising(1);
with["commitments"][0]["reaffirmed"] = json!([{ "at": (now() - chrono::Duration::hours(3)).to_rfc3339(), "event": "11", "words": "I'll send the render tonight, promise." }]);
let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1);
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\". Said again 3 h ago: \"I'll send the render tonight, promise.\". She has no way to do it yet."), "{}", packet.in_view);
assert_eq!(packet.in_view.matches("render tonight, part 0").count(), 1);
}