diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs
index 96c8ff4..f6b7a1d 100644
--- a/crates/mind-body/src/projection/interpret.rs
+++ b/crates/mind-body/src/projection/interpret.rs
@@ -18,9 +18,10 @@
//! the turn's room. Whether a draft tells what she knows privately is a reading of its meaning, so it is the
//! Interpreter's judgement over the private items the packet lists to it (`Packet::private`), never a word match here.
//! Every refusal and drop is reported. Every gap is typed (`GapKind`) and shown to her later (K9) only as what it is: a
-//! draft by number, or a located passage of her thought (`gap`). Each line she says carries a required `promises`: the
-//! words of it that promise an act she cannot do, or null; found in the draft, code records them as the
-//! `missing_affordance` gap (map 16.21), and not found, they are reported and record none. The prompt tells the Interpreter what she can do this
+//! draft by number, or a located passage of her thought (`gap`). Each line she says, and each addition, carries a
+//! required `promises`: the words of it that promise an act she cannot do, or null; when they are at least
+//! `PROMISE_MIN_WORDS` words found in the draft (`promise_found`), code records them as the `missing_affordance` gap
+//! (map 16.21), and otherwise they are reported (`promises_unused`) and record none. The prompt tells the Interpreter what she can do this
//! turn (`select::turn_words`), so a reach past it is a `missing_affordance` gap. Nothing here posts: the commit (C3c)
//! will.
//!
@@ -46,6 +47,9 @@ const ECHO_OVERLAP: f64 = 0.8;
/// she meant, and is kept as unlocated.
const GAP_QUOTE_MIN_WORDS: usize = 4;
+/// The fewest words the words of a draft that promise an act may be: fewer ("the") name no act.
+const PROMISE_MIN_WORDS: usize = 4;
+
/// The marks of a draft: two literal tokens no natural prose holds (map 16.19.1).
pub(crate) const DRAFT_OPEN: &str = "";
pub(crate) const DRAFT_CLOSE: &str = "";
@@ -55,7 +59,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"],"properties":{"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"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"reply_to":{"type":["string","null"]},"promises":{"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"}}}}}}"#;
+pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest"],"properties":{"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":["string","null"]}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"reply_to":{"type":["string","null"]},"promises":{"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
@@ -75,7 +79,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 Matrix id of the person whose message {subj} answer{s} (`reply_to`, or null), and the words of the draft that promise an act {subj} {has} no way to do, now or later, copied exactly (`promises`, or null when it promises none). `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, and the draft that is {poss} addition. 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.
+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 Matrix id of the person whose message {subj} answer{s} (`reply_to`, or null), and the words of the draft that promise an act {subj} {has} no way to do, now or later, copied exactly (`promises`, or null when it promises none). `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 its words that promise an act {subj} {has} no way to do, copied exactly (`promises`, or null). 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.
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 and wrote no draft of it. Every intent of {poss} that is not carried out has a kind: an intent to act is missing_affordance, an intent to say 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" },
@@ -323,13 +327,16 @@ struct ProposedNote {
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.
+/// An amendment as the model proposes it: the id of a line she may add to, the draft that is her addition, and its
+/// words that promise an act she has no way to do (as a line's `promises`).
#[derive(Debug, Deserialize)]
struct ProposedAmend {
#[serde(default)]
target: Option,
#[serde(default)]
draft: Option,
+ #[serde(default)]
+ promises: Option,
}
#[derive(Debug, Deserialize)]
@@ -438,7 +445,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
let mut used: Vec = Vec::new();
let mut went: Vec<&Draft> = Vec::new();
let mut said_drafts: Vec = Vec::new();
- let mut unfound: Vec = Vec::new();
+ let mut unused: Vec = Vec::new();
for line in parsed.say {
let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else {
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
@@ -471,20 +478,12 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
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 } }));
- // A promise in a line she says is a gap code derives (map 16.21): the field is required of every line, so the
- // judgement is made for each. Words not found in the draft are reported and record no gap; a reach the answer
- // already gapped on this draft is not recorded twice.
- if let Some(promise) = line.promises.as_deref().map(str::trim).filter(|promise| !promise.is_empty()) {
- if !draft.text.contains(promise) {
- unfound.push(json!({ "draft": draft.n, "promises": promise }));
- } else if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n))) {
- gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": promise, "detail": null }));
- }
- }
+ promised(&mut decision, &mut unused, draft, line.promises.as_deref());
}
// An amendment adds a whole draft after a line of hers listed as one she may add to; the actuator composes it, so
// nothing here can rewrite the line (map 16.17).
let mut amended: Vec = Vec::new();
+ let mut amended_drafts: Vec = Vec::new();
for proposed in parsed.amend {
let Some(draft) = proposed.draft.and_then(|n| found.numbered(n)) else {
refusals.push(refused(Act::Amend, None, proposed.draft, Refusal::NoDraft));
@@ -504,7 +503,9 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
(None, Some(line)) => {
used.push(draft.n);
went.push(draft);
+ amended_drafts.push(draft.n);
amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n }));
+ promised(&mut decision, &mut unused, draft, proposed.promises.as_deref());
}
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
}
@@ -542,9 +543,10 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
suggestions.push(json!({ "kind": proposed.kind, "about": about, "room": room, "text": draft.text, "draft": draft.n, "dropped": { "about": dropped } }));
}
// A gap about a draft that went somewhere, or quoting from one, contradicts what happened: it is kept for the trace as
- // `acted` and never shown to her. A reach naming a draft she said is a promise she cannot keep, and is kept (16.20.6).
+ // `acted` and never shown to her. A reach naming a draft she said or added is a promise she cannot keep, and is kept
+ // (16.20.6, 16.21).
for gap in decision["gaps"].as_array_mut().into_iter().flatten() {
- let promise = gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"].as_u64().is_some_and(|n| said_drafts.iter().any(|said| *said as u64 == n));
+ let promise = gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"].as_u64().is_some_and(|n| said_drafts.iter().chain(&amended_drafts).any(|said| *said as u64 == n));
let named = !promise && gap["draft"].as_u64().is_some_and(|n| went.iter().any(|draft| draft.n as u64 == n)) && gap["from"] == "draft";
let quoted = gap["from"] == "unlocated" && gap["quote"].as_str().is_some_and(|quote| !quote.is_empty() && went.iter().any(|draft| draft.text.contains(quote)));
if named || quoted {
@@ -557,11 +559,44 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
decision["room_kind"] = json!(packet.room_kind);
decision["said"] = json!(said);
decision["refused"] = json!(refusals);
- if !unfound.is_empty() {
- decision["promises_not_found"] = json!(unfound);
+ if !unused.is_empty() {
+ decision["promises_unused"] = json!(unused);
}
decision
}
+/// Her words compared as a promise is found in a draft: case-blind, and a curly apostrophe or single quote read as a
+/// straight one.
+fn folded(text: &str) -> String {
+ text.to_lowercase().replace(['\u{2018}', '\u{2019}'], "'")
+}
+
+/// Whether `promise` names an act in `draft`: at least `PROMISE_MIN_WORDS` words, found in the draft's text as `folded`
+/// reads both. Why not, when not.
+fn promise_found(draft: &str, promise: &str) -> Result<(), &'static str> {
+ let promise = folded(promise);
+ if promise.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).count() < PROMISE_MIN_WORDS {
+ Err("fewer than four words")
+ } else if !folded(draft).contains(&promise) {
+ Err("not in the draft")
+ } else {
+ Ok(())
+ }
+}
+
+/// A promise in a draft she says or adds is a gap code derives (map 16.21): the field is required of every line and
+/// every addition, so the judgement is made for each. Words that do not name an act in the draft (`promise_found`) are
+/// reported in `unused` and record no gap; a reach the answer already gapped on this draft is not recorded twice.
+fn promised(decision: &mut Value, unused: &mut Vec, draft: &Draft, promises: Option<&str>) {
+ let Some(promise) = promises.map(str::trim).filter(|promise| !promise.is_empty()) else {
+ return;
+ };
+ if let Err(why) = promise_found(&draft.text, promise) {
+ unused.push(json!({ "draft": draft.n, "promises": promise, "why": why }));
+ } else if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n))) {
+ gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": promise, "detail": null }));
+ }
+}
+
#[cfg(test)]
pub(crate) mod tests;
diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs
index 3552f13..24cbefc 100644
--- a/crates/mind-body/src/projection/interpret/tests.rs
+++ b/crates/mind-body/src/projection/interpret/tests.rs
@@ -563,9 +563,9 @@ fn k21_a_lines_promises_words_found_in_it_are_the_promise_gap() {
let told = crate::projection::outcome::outcome_of(&record).unwrap().lines(packet().forms);
assert_eq!(told, ["- #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."]);
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll mail you the render." }], "gaps": [] }));
- assert_eq!((unfound["gaps"].as_array().unwrap().len(), unfound["promises_not_found"].clone()), (0, json!([{ "draft": 1, "promises": "I'll mail you the render." }])), "{unfound}");
+ assert_eq!((unfound["gaps"].as_array().unwrap().len(), unfound["promises_unused"].clone()), (0, json!([{ "draft": 1, "promises": "I'll mail you the render.", "why": "not in the draft" }])), "{unfound}");
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": null }], "gaps": [] }));
- assert!(none["gaps"].as_array().unwrap().is_empty() && none.get("promises_not_found").is_none(), "{none}");
+ assert!(none["gaps"].as_array().unwrap().is_empty() && none.get("promises_unused").is_none(), "{none}");
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
assert_eq!(twice["gaps"].as_array().unwrap().len(), 1, "{twice}");
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
@@ -642,3 +642,41 @@ 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}");
}
+
+/// Soul at 964ee50: "the" made "Also the kettle sounds fine." a promise; a promise's words differing from the draft
+/// only in case or in a curly apostrophe were reported not found; an addition could not carry a promise.
+#[test]
+fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_one_too() {
+ let prose = "Missed you too. I'll send the render tonight. Also the kettle sounds fine.";
+ let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "reply_to": null, "promises": promises }], "gaps": [] }));
+ let short = say(2, "the");
+ assert_eq!((short["gaps"].as_array().unwrap().len(), short["promises_unused"].clone()), (0, json!([{ "draft": 2, "promises": "the", "why": "fewer than four words" }])), "{short}");
+ assert_eq!(say(1, "the render tonight")["promises_unused"][0]["why"], "fewer than four words");
+ for promises in ["i'll send the render tonight", "I\u{2019}ll send the render tonight.", "I\u{2018}LL SEND THE RENDER TONIGHT"] {
+ let decision = say(1, promises);
+ assert_eq!((decision["gaps"][0]["kind"].as_str(), decision["gaps"][0]["promises"].as_str(), decision.get("promises_unused")), (Some("missing_affordance"), Some(promises), None), "{promises}: {decision}");
+ }
+ let curly = answered(&packet(), "I\u{2019}ll send the render tonight.", json!({ "say": [{ "draft": 1, "mentions": [], "reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
+ assert_eq!(curly["gaps"][0]["kind"], "missing_affordance", "a curly apostrophe in the draft: {curly}");
+
+ // An addition's promise: the same derivation, kept (not `acted`), and told on the addition's row.
+ let prose = "I should fix that. I'll send the file tomorrow instead, first thing.";
+ let amend = |promises: Value| answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "promises": promises }] }));
+ let decision = amend(json!("I'll send the file tomorrow"));
+ let gap = &decision["gaps"][0];
+ assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the file tomorrow")), "{decision}");
+ let told = |edited: Value| {
+ let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": edited })).unwrap();
+ (outcome.lines(packet().forms), outcome.omitted)
+ };
+ let (made, omitted) = told(json!([{ "event": "$ev-1", "refusal": null }]));
+ assert_eq!(made, ["- #minds:gamecult.org has his line, now ending with: \"I'll send the file tomorrow instead, first thing.\". The rest of the line is as it was. What he added promises something he has no way to do, now or later, and it will not happen by itself."]);
+ assert!(omitted.is_empty(), "{omitted:?}");
+ let (refused, omitted) = told(json!([{ "event": "$ev-1", "refusal": "not_found" }]));
+ assert_eq!(refused, ["- Nothing changed in #minds:gamecult.org: the line is gone. He wrote: \"I'll send the file tomorrow instead, first thing.\"."], "nothing was added, so nothing is promised");
+ assert!(omitted.iter().any(|why| why.contains("an addition that was not made")), "{omitted:?}");
+ assert_eq!(amend(json!("send"))["promises_unused"][0]["why"], "fewer than four words");
+ assert!(amend(Value::Null)["gaps"].as_array().unwrap().is_empty());
+ let prompt = speech_prompt(&amendable_packet(), "x", "y", &Tuning::default());
+ assert!(prompt.contains("and its words that promise an act he has no way to do, copied exactly (`promises`, or null)") && SPEECH_SCHEMA.contains(r#""required":["target","draft","promises"]"#), "{prompt}");
+}
diff --git a/crates/mind-body/src/projection/outcome.rs b/crates/mind-body/src/projection/outcome.rs
index 0c2a290..a2a4261 100644
--- a/crates/mind-body/src/projection/outcome.rs
+++ b/crates/mind-body/src/projection/outcome.rs
@@ -61,8 +61,9 @@ enum Part {
Refused { reason: Refusal, room: Option, text: String },
Gap { kind: GapKind, room: Option, quote: Quote },
Unfinished { room: Option, text: String },
- /// An edited receipt with no refusal: her words were added after a line of hers.
- Amended { room: String, added: String },
+ /// An edited receipt with no refusal: her words were added after a line of hers; `promise` when a
+ /// `missing_affordance` gap names the addition's draft (map 16.21).
+ Amended { room: String, added: String, promise: bool },
/// An addition that changed nothing: refused by code (None) or by the actuator.
NotAmended { refusal: Option, room: Option, added: String },
/// A note to Self, recorded in her turn's record: never claimed read.
@@ -121,6 +122,8 @@ pub(crate) fn outcome_of(record: &Value) -> Option {
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();
+ // Each addition's draft, and the part that tells it when the actuator made it.
+ let mut additions: Vec<(&Value, Option)> = Vec::new();
let mut receipts: Vec = Vec::new();
for receipt in record["posted"].as_array().into_iter().flatten() {
let (Some(event), Some(room), Some(text)) = (words(&receipt["event"]), words(&receipt["room"]), words(&receipt["text"])) else {
@@ -150,8 +153,10 @@ pub(crate) fn outcome_of(record: &Value) -> Option {
continue;
};
let receipt = record["edited"].as_array().into_iter().flatten().find(|receipt| receipt["event"] == amended["event"]);
+ let made = receipt.is_some_and(|receipt| receipt["refusal"].is_null());
+ additions.push((&amended["draft"], made.then_some(outcome.parts.len())));
match receipt.map(|receipt| (receipt["refusal"].is_null(), serde_json::from_value::(receipt["refusal"].clone()))) {
- Some((true, _)) => outcome.parts.push(Part::Amended { room: at, added }),
+ Some((true, _)) => outcome.parts.push(Part::Amended { room: at, added, promise: false }),
Some((false, Ok(refusal))) => outcome.parts.push(Part::NotAmended { refusal: Some(refusal), room: Some(at), added }),
Some((false, Err(_))) => outcome.omitted.push(format!("an amendment refused for a reason no table names: {}", receipt.map_or(Value::Null, |receipt| receipt["refusal"].clone()))),
None => outcome.omitted.push(format!("an amendment with no receipt that it was made: {}", amended["added"])),
@@ -162,6 +167,19 @@ pub(crate) fn outcome_of(record: &Value) -> Option {
let mut promised: Vec = Vec::new();
for gap in decision["gaps"].as_array().into_iter().flatten() {
let kind = serde_json::from_value::(gap["kind"].clone()).unwrap_or(GapKind::Unresolved);
+ // A reach naming an addition's draft is a promise in that addition: told on the addition's row when the actuator
+ // made it; when it did not, the row that says nothing changed tells it, and the promise is reported.
+ if let Some((_, made)) = additions.iter().find(|(draft, _)| kind == GapKind::MissingAffordance && gap["from"] == "draft" && **draft == gap["draft"]) {
+ match made {
+ Some(at) => {
+ if let Part::Amended { promise, .. } = &mut outcome.parts[*at] {
+ *promise = true;
+ }
+ }
+ None => outcome.omitted.push(format!("a promise in an addition that was not made: {}", gap["words"])),
+ }
+ continue;
+ }
let quote = match (gap["from"].as_str(), words(&gap["words"])) {
(Some("draft"), Some(_)) if echoes.contains(&&gap["draft"]) => Some(Quote::Sent),
(Some("draft"), Some(text)) => Some(Quote::Wrote(text)),
@@ -223,7 +241,7 @@ impl Part {
match self {
Self::Failed => 0,
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) => 1,
- Self::Promise { .. } => 2,
+ Self::Promise { .. } | Self::Amended { promise: true, .. } => 2,
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) => 3,
Self::BrokeAfter { .. } => 4,
}
@@ -237,7 +255,7 @@ impl Part {
let place = |room: &Option| room.clone().unwrap_or_else(|| "the room".to_owned());
match self {
Self::Said { room, text } | Self::Promise { room, text } => format!("{} has, from {obj}: {}.", capitalized(room), quoted(text)),
- Self::Amended { room, added } => format!("{} has {poss} line, now ending with: {}.", capitalized(room), quoted(added)),
+ Self::Amended { room, added, .. } => format!("{} has {poss} line, now ending with: {}.", capitalized(room), quoted(added)),
Self::NoteLeft(text) => format!("{cap_subj} left Self a note: {}.", quoted(text)),
Self::Refused { reason: Refusal::Echo, room, .. } | Self::Gap { kind: GapKind::Conditional | GapKind::Unwritten | GapKind::Unresolved, room, .. } => format!("Nothing reached {}.", place(room)),
Self::Refused { reason: Refusal::NoRoom, .. } => "Nothing reached anyone.".to_owned(),
@@ -269,7 +287,8 @@ impl Part {
};
match self {
Self::Said { .. } => String::new(),
- Self::Amended { .. } => " The rest of the line is as it was.".to_owned(),
+ Self::Amended { promise: false, .. } => " The rest of the line is as it was.".to_owned(),
+ Self::Amended { promise: true, .. } => format!(" The rest of the line is as it was. What {subj} added promises something {subj} {has} no way to do, now or later, and it will not happen by itself."),
Self::Promise { .. } => format!(" It promises something {subj} {has} no way to do, now or later, and it will not happen by itself. The line stands as {subj} wrote it; {subj} can add to it."),
Self::NoteLeft(_) => format!(" It waits in Self's inbox until Self reads it; nothing tells {obj} when, and nothing in it happens by itself."),
Self::Refused { reason: Refusal::Echo, .. } => format!(" What {subj} wrote was mostly the words {subj} had just been sent, so none of it was sent."),