Persona K61/K63/K64: an act stated as under way is done by the decision or is her promise; one draft, one row, "had drafted"; a read need on a target already read is words
K61 (map 16.33.5): each promise entry carries `now` and `done_by` (a draft said or added, the read, or the note). A
`done_by` naming an act the answer does not make is a contract fault, asked again once; after a failed retry it reads as
null. At the decision an act is done only by an act that happened (a draft said or added, the read made, the note left);
anything else opens as her promise, and one opened open from a `now` entry is told next turn ("nothing in her turn did
it"; `Applied.now_opened`, `Part::NowUndone`). Promises are decided after the read resolves.
K63: a `missing_affordance` gap naming a draft that did not go out is a clause of that draft's row, never its own row
(a superseded draft, which no row tells, keeps the reach row); every row of an unsent draft ends "had drafted".
K64: a read need whose target a found read of this conversation already holds opens as `words`, with `readBefore`
{at, of} (persona_state.v0 gains the optional field); the reaffirm narrowing path does the same. Her view renders
"read it {when}, before this promise", and never "not read it yet" beside a read of the same target in the conversation.
Replays from R16: X.3 r2 and r8, E.5 r1, X.5 r5/r6.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
aa431fc139
commit
8ffb4fe6a8
13 changed files with 707 additions and 127 deletions
File diff suppressed because one or more lines are too long
|
|
@ -138,6 +138,9 @@ pub(crate) enum Proposal {
|
|||
needs: Option<Needs>,
|
||||
#[serde(default)]
|
||||
reached: bool,
|
||||
/// Her line said she was doing it now or had just done it, and no act of her turn did it (K61, map 16.33.5).
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
now: bool,
|
||||
evidence: Evidence,
|
||||
},
|
||||
/// Every close cites `thought`, a passage of her prose this turn that takes the close up, and says whether her prose
|
||||
|
|
@ -246,7 +249,7 @@ pub(crate) enum Refusal {
|
|||
///
|
||||
/// | proposal | evidence | needs | bound |
|
||||
/// |---|---|---|---|
|
||||
/// | `promise_open` | `Draft` | the line went out | one promise per person per draft; `reaffirms` an open one of the same person's opens none, and narrows a search need to a read of one thing in its repo (`narrows`) |
|
||||
/// | `promise_open` | `Draft` | the line went out | one promise per person per draft; `reaffirms` an open one of the same person's opens none, and narrows a search need to a read of one thing in its repo (`narrows`); a read need on a target a read of this conversation found is `words`, with `readBefore` (K64) |
|
||||
/// | `promise_close` kept | `Draft` | the line went out; `needs` typed; for a `Read` need, a read of its target behind the line: this wake before the draft was typed, this conversation, or the entry's receipt | 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 |
|
||||
|
|
@ -368,6 +371,9 @@ pub(crate) struct Applied {
|
|||
/// The `carry` entries a hold had no room left for whole under `CARRIES_BYTES` (K51, K57): carried clipped to the room
|
||||
/// left, or, with none, not carried, so that what it already carries stays.
|
||||
pub carries_full: Vec<Value>,
|
||||
/// The entries opened open from an act her line said she was doing now, which nothing in her turn did (K61), as they
|
||||
/// now stand: her next outcome tells each.
|
||||
pub now_opened: Vec<Value>,
|
||||
}
|
||||
|
||||
/// The one applier: her state with one turn's proposals applied, as deltas to `state` as it stands at commit, and what
|
||||
|
|
@ -569,6 +575,15 @@ fn narrows(entry: &Value, needs: &Needs) -> Option<ReadRequest> {
|
|||
(need.search() && !named.search() && one_thing).then(|| named.clone())
|
||||
}
|
||||
|
||||
/// The read of this conversation that found what `request` reads, by its normal form, as `readBefore` records it (K64):
|
||||
/// when it was made, and what it read. None when no read of it found anything, or the record gives no time.
|
||||
fn read_before(request: &ReadRequest, record: &Value) -> Option<Value> {
|
||||
let key = request.normal();
|
||||
let read = record["interpreter"]["conversation_reads"].as_array()?.iter().find(|read| read["found"] == true && read["key"].as_str() == Some(key.as_str()))?;
|
||||
let at = read["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok())?;
|
||||
Some(json!({ "at": at.with_timezone(&Utc).to_rfc3339(), "of": key }))
|
||||
}
|
||||
|
||||
/// The normal form of what a read's receipt read.
|
||||
fn read_key(read: &Value) -> Option<String> {
|
||||
serde_json::from_value::<ReadRequest>(read["request"].clone()).ok().map(|request| request.normal())
|
||||
|
|
@ -621,7 +636,7 @@ fn apply_promise(state: &mut Value, started: &Value, proposal: &Proposal, resolv
|
|||
state["commitments"] = json!([]);
|
||||
}
|
||||
match (proposal, resolved) {
|
||||
(Proposal::PromiseOpen { words: promised, to, reaffirms, needs, reached, .. }, Resolved::Sent { event, room, text: posted, .. }) => {
|
||||
(Proposal::PromiseOpen { words: promised, to, reaffirms, needs, reached, now: stated_now, .. }, Resolved::Sent { event, room, text: posted, .. }) => {
|
||||
// Distinct promises to one person each open their own entry (Soul's R7); a promise said again is one only by
|
||||
// `reaffirms`.
|
||||
if let Some(id) = reaffirms {
|
||||
|
|
@ -646,8 +661,15 @@ fn apply_promise(state: &mut Value, started: &Value, proposal: &Proposal, resolv
|
|||
// narrows the need to it, and its receipt goes with the old target (map 16.28.6). Any other `needs` on a
|
||||
// reaffirmation is ignored: a `words` one never drops a read need.
|
||||
if let Some(narrower) = needs.as_ref().and_then(|needs| narrows(entry, needs)) {
|
||||
entry["needs"] = json!(Needs::Read { request: narrower });
|
||||
clear_receipt(entry);
|
||||
// A read of this conversation already read the one thing (K64): what she has keeps it.
|
||||
match read_before(&narrower, record) {
|
||||
Some(before) => {
|
||||
entry["needs"] = json!(Needs::Words);
|
||||
entry["readBefore"] = before;
|
||||
}
|
||||
None => entry["needs"] = json!(Needs::Read { request: narrower }),
|
||||
}
|
||||
}
|
||||
applied.reaffirmed.push(entry.clone());
|
||||
return Ok(());
|
||||
|
|
@ -658,6 +680,13 @@ fn apply_promise(state: &mut Value, started: &Value, proposal: &Proposal, resolv
|
|||
return Err(Refusal::AlreadyOpen);
|
||||
}
|
||||
let words = words_of(&posted, promised);
|
||||
// A read need whose target a read of this conversation already found is kept by what she has (K64): the body
|
||||
// refuses that read again (K26), so the need is her words, and the read it rests on is recorded.
|
||||
let before = match needs {
|
||||
Some(Needs::Read { request }) => read_before(request, record),
|
||||
_ => None,
|
||||
};
|
||||
let needs = if before.is_some() { Some(Needs::Words) } else { needs.clone() };
|
||||
// Whether it opens is derived (map 16.25.2): words open; a read opens when code found its target within reach;
|
||||
// something lacking, or a need not named, is blocked.
|
||||
let open = opens(needs.as_ref(), *reached);
|
||||
|
|
@ -668,7 +697,14 @@ fn apply_promise(state: &mut Value, started: &Value, proposal: &Proposal, resolv
|
|||
if let Some(needs) = needs {
|
||||
entry["needs"] = json!(needs);
|
||||
}
|
||||
if let Some(before) = before {
|
||||
entry["readBefore"] = before;
|
||||
}
|
||||
entries.push(entry.clone());
|
||||
// Told once, as what nothing in her turn did, when it opens: a blocked one is told by her line's gap.
|
||||
if *stated_now && open {
|
||||
applied.now_opened.push(entry.clone());
|
||||
}
|
||||
applied.opened.push(entry);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn record(state: Value, promises: Value, posted: bool) -> Value {
|
|||
|
||||
/// A promise opened on draft 1 needing `needs`, its read reached or not.
|
||||
fn open_needing(to: &str, needs: Option<Needs>, reached: bool) -> Value {
|
||||
json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(to.into()), reaffirms: None, needs, reached, evidence: Evidence::Draft(1) })
|
||||
json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(to.into()), reaffirms: None, needs, reached, now: false, evidence: Evidence::Draft(1) })
|
||||
}
|
||||
|
||||
/// A promise her words keep (`can`), or one this body lacks.
|
||||
|
|
@ -156,7 +156,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, reaffirms: None, needs: Some(Needs::Words), reached: false, evidence: Evidence::Heard("q1".into()) });
|
||||
let heard_open = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: None, reaffirms: None, needs: Some(Needs::Words), reached: false, now: false, 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 (state, applied) = apply(&holding("open"), &record(json!([heard_open, heard_keep, prose_release, { "kind": "feel", "evidence": { "heard": "q1" } }]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
|
|
@ -180,8 +180,8 @@ fn b1_telling_the_person_she_cannot_do_it_withdraws_a_blocked_promise() {
|
|||
/// same words to the same person twice open once. Nothing else merges them: a promise said again is one by `reaffirms`.
|
||||
#[test]
|
||||
fn b3_one_line_opens_one_entry_per_distinct_promise() {
|
||||
let other = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(META.into()), reaffirms: None, needs: Some(Needs::Words), reached: false, evidence: Evidence::Draft(1) });
|
||||
let to_kiko = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(KIKO.into()), reaffirms: None, needs: Some(Needs::Words), reached: false, evidence: Evidence::Draft(1) });
|
||||
let other = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(META.into()), reaffirms: None, needs: Some(Needs::Words), reached: false, now: false, evidence: Evidence::Draft(1) });
|
||||
let to_kiko = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(KIKO.into()), reaffirms: None, needs: Some(Needs::Words), reached: false, now: false, evidence: Evidence::Draft(1) });
|
||||
let (state, applied) = apply(&json!({}), &record(json!([open(false), other.clone(), to_kiko, other]), 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", META), ("the render tonight", KIKO)], "{applied:?}");
|
||||
|
|
@ -256,7 +256,7 @@ fn b7_a_closed_entry_without_a_close_time_is_stamped_then_pruned_a_week_later()
|
|||
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()), reaffirms: Some("c1".into()), needs: Some(Needs::Words), reached: false, evidence: Evidence::Draft(1) });
|
||||
let proposal = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(to.into()), reaffirms: Some("c1".into()), needs: Some(Needs::Words), reached: false, now: false, evidence: Evidence::Draft(1) });
|
||||
apply(&state, &record(json!([proposal]), shown(status), true), PROSE, "r1-t2", now())
|
||||
};
|
||||
let (state, applied) = again(META, "open");
|
||||
|
|
@ -269,7 +269,7 @@ fn k27_a_promise_said_again_reaffirms_the_entry_and_opens_none() {
|
|||
// 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()), reaffirms: Some("c1".into()), needs: Some(Needs::Words), reached: false, evidence: Evidence::Draft(1) });
|
||||
let proposal = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(META.into()), reaffirms: Some("c1".into()), needs: Some(Needs::Words), reached: false, now: false, 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;
|
||||
|
|
@ -710,7 +710,7 @@ fn f2_r7(entry_needs: &Needs, needs: Option<Needs>) -> (Value, Applied) {
|
|||
c1["commitments"][0]["readAt"] = json!((now() - Duration::minutes(10)).to_rfc3339());
|
||||
c1["commitments"][0]["readId"] = json!("r1-t13-r1");
|
||||
c1["commitments"][0]["readOf"] = json!(ReadRequest::Repo(PASSKEY_SEARCH.into()).normal());
|
||||
let again = json!(Proposal::PromiseOpen { words: "I'll open #85 next and come back with what it does.".into(), to: Some(KIKO.into()), reaffirms: Some("c1".into()), needs, reached: true, evidence: Evidence::Draft(1) });
|
||||
let again = json!(Proposal::PromiseOpen { words: "I'll open #85 next and come back with what it does.".into(), to: Some(KIKO.into()), reaffirms: Some("c1".into()), needs, reached: true, now: false, evidence: Evidence::Draft(1) });
|
||||
apply(&c1, &turn_saying(&c1, KIKO, F2_R7_DRAFT, json!([again])), F2_R7_PROSE, "r1-t14", now())
|
||||
}
|
||||
|
||||
|
|
@ -1068,3 +1068,55 @@ fn k51_carry_reads_the_decision_carry_and_nothing_else() {
|
|||
let (after, applied) = apply(&state, &record, "x", "r1-t4", now());
|
||||
assert_eq!((after["holds"][0]["carries"].clone(), after["holds"][1].get("carries"), applied.held_unrecorded.clone(), applied.carries_full.len()), (json!(["One.", "Two."]), None, vec![carry("h9", "Lost.")], 0), "{after}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K64 (map 16.33.5): a promise never needs a read the body will refuse.
|
||||
|
||||
const PASP: &str = "https://ccrma.stanford.edu/~jos/pasp/";
|
||||
|
||||
/// `record` with this conversation's reads, as the decision lists them.
|
||||
fn with_reads(mut rec: Value, reads: Value) -> Value {
|
||||
rec["interpreter"]["conversation_reads"] = reads;
|
||||
rec
|
||||
}
|
||||
|
||||
fn pasp_need() -> Needs {
|
||||
Needs::Read { request: ReadRequest::Web(PASP.into()) }
|
||||
}
|
||||
|
||||
fn pasp_read(found: bool, at: Value) -> Value {
|
||||
json!([{ "key": ReadRequest::Web(PASP.into()).normal(), "found": found, "at": at }])
|
||||
}
|
||||
|
||||
/// A read need on a target a read of this conversation found opens as her words, with the read it rests on; a target no
|
||||
/// read found, or one read with no time, opens needing the read as before.
|
||||
#[test]
|
||||
fn k64_a_read_need_on_a_target_already_read_is_words() {
|
||||
let read_at = now() - Duration::minutes(30);
|
||||
let (state, applied) = apply(&json!({}), &with_reads(record(json!([open_needing(META, Some(pasp_need()), true)]), json!([]), true), pasp_read(true, json!(read_at.to_rfc3339()))), PROSE, "r1-t13", now());
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["needs"].clone(), entry["status"].as_str(), entry["readBefore"].clone()), (json!(Needs::Words), Some("open"), json!({ "at": read_at.to_rfc3339(), "of": ReadRequest::Web(PASP.into()).normal() })), "{state}");
|
||||
assert_eq!(applied.opened.len(), 1);
|
||||
// A keep later rests on her words alone.
|
||||
let mut keep = turn_saying(&state, META, "I'll send the render tonight.", json!([close(How::Kept, Evidence::Draft(1))]));
|
||||
keep["interpreter"]["promises"][0]["entry"] = entry["id"].clone();
|
||||
let (_, kept) = apply(&state, &keep, PROSE, "r1-t14", now());
|
||||
assert_eq!((kept.closed.len(), reasons(&kept)), (1, vec![]), "{kept:?}");
|
||||
for reads in [pasp_read(false, json!(read_at.to_rfc3339())), pasp_read(true, Value::Null), json!([])] {
|
||||
let (state, _) = apply(&json!({}), &with_reads(record(json!([open_needing(META, Some(pasp_need()), true)]), json!([]), true), reads.clone()), PROSE, "r1-t13", now());
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["needs"].clone(), entry.get("readBefore")), (json!(pasp_need()), None), "{reads}: {state}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A reaffirmation that narrows a search to one thing a read of this conversation already found narrows it to her words.
|
||||
#[test]
|
||||
fn k64_a_reaffirm_narrowing_to_an_item_already_read_is_words() {
|
||||
let c1 = holding_one(KIKO, F2_PROMISE, &search_need(), "open");
|
||||
let again = json!(Proposal::PromiseOpen { words: "I'll open #85 next and come back with what it does.".into(), to: Some(KIKO.into()), reaffirms: Some("c1".into()), needs: Some(read_need("GameCult/Bifrost#85")), reached: true, now: false, evidence: Evidence::Draft(1) });
|
||||
let read_at = now() - Duration::minutes(5);
|
||||
let reads = json!([{ "key": ReadRequest::Repo("GameCult/Bifrost#85".into()).normal(), "found": true, "at": read_at.to_rfc3339() }]);
|
||||
let (state, applied) = apply(&c1, &with_reads(turn_saying(&c1, KIKO, F2_R7_DRAFT, json!([again])), reads), F2_R7_PROSE, "r1-t14", now());
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["needs"].clone(), entry["readBefore"]["of"].as_str(), applied.reaffirmed.len()), (json!(Needs::Words), Some(ReadRequest::Repo("GameCult/Bifrost#85".into()).normal().as_str()), 1), "{state}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,14 @@ pub(crate) struct Shown {
|
|||
pub(crate) text: String,
|
||||
}
|
||||
|
||||
/// A read she made in this conversation: its normal form, whether it found anything, and what it was in code's words.
|
||||
/// A read she made in this conversation: its normal form, whether it found anything, what it was in code's words, and when
|
||||
/// she made it (K64: a promise made after it is kept by what she has).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
|
||||
pub(crate) struct Tried {
|
||||
pub(crate) key: String,
|
||||
pub(crate) found: bool,
|
||||
pub(crate) what: String,
|
||||
pub(crate) at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
fn at_of(record: &Value) -> Option<DateTime<Utc>> {
|
||||
|
|
@ -116,7 +118,7 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime<Utc>, her
|
|||
let found = read["ok"] == true;
|
||||
if found || read["failure"] == "not_found" {
|
||||
exchange.tried.retain(|tried| tried.key != request.normal());
|
||||
exchange.tried.push(Tried { key: request.normal(), found, what: read["what"].as_str().unwrap_or_default().to_owned() });
|
||||
exchange.tried.push(Tried { key: request.normal(), found, what: read["what"].as_str().unwrap_or_default().to_owned(), at: *at });
|
||||
}
|
||||
}
|
||||
for read in decision["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == true) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fn r7_a_not_found_read_is_remembered_and_a_broken_one_is_not() {
|
|||
let missing = json!({ "ok": false, "failure": "not_found", "request": { "kind": "repo", "target": "GameCult/Bifrost?q=Consent Receipt" }, "what": "a search" });
|
||||
let broken = json!({ "ok": false, "failure": "failed", "request": { "kind": "repo", "target": "GameCult/Lodur" }, "what": "GameCult/Lodur on the forge" });
|
||||
let exchange = exchange_of(&[turn(10, MINDS, &[], json!([missing, broken]), json!([]), json!([]))], MINDS, now(), her());
|
||||
assert_eq!(exchange.tried, [Tried { key: "repo:gamecult/bifrost?q=consent receipt".into(), found: false, what: "a search".into() }]);
|
||||
assert_eq!(exchange.tried, [Tried { key: "repo:gamecult/bifrost?q=consent receipt".into(), found: false, what: "a search".into(), at: exchange.tried[0].at }]);
|
||||
}
|
||||
|
||||
/// Soul's R8: the reads refused in the conversation are carried, once each, as `kind target (why)`.
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -554,7 +554,7 @@ fn a_note_needs_no_room_and_speech_does() {
|
|||
assert_eq!(refusals(&decision), [("say".to_owned(), "no_room".to_owned())]);
|
||||
// He is told the line he meant to say had nowhere to go (Soul at 0cfc386: it was omitted).
|
||||
let outcome = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] }), &crate::projection::select::Names::none()).unwrap();
|
||||
assert!(outcome.lines(packet().forms).contains(&"- Nothing reached anyone. That turn had no room for him to speak in, so it was not sent: \"Another thought.\".".to_owned()), "{:?}", outcome.lines(packet().forms));
|
||||
assert!(outcome.lines(packet().forms).contains(&"- Nothing reached anyone. That turn had no room for him to speak in, so it was not sent. He had drafted: \"Another thought.\".".to_owned()), "{:?}", outcome.lines(packet().forms));
|
||||
assert!(outcome.omitted.is_empty(), "{:?}", outcome.omitted);
|
||||
}
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ fn k21_a_lines_promises_words_found_in_it_are_the_promise_gap() {
|
|||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "needs": { "kind": "lacking", "read": null } }] }], "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());
|
||||
assert!(prompt.contains("(`promises`, a list, empty when it promises nothing)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","holds","clear_of","promises"]"#), "{prompt}");
|
||||
assert!(prompt.contains("(`promises`, a list, empty when it promises nothing and says of no act that he is doing it)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","holds","clear_of","promises"]"#), "{prompt}");
|
||||
}
|
||||
|
||||
/// Soul's probe at 0cfc386: the reach names no draft and quotes the said one by its words. It is the promise on that draft,
|
||||
|
|
@ -747,7 +747,7 @@ fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_
|
|||
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_eq!(refused, ["- Nothing changed in #minds:gamecult.org: the line is gone. He had drafted: \"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());
|
||||
|
|
@ -783,7 +783,7 @@ fn b3_a_line_carries_several_promises_and_each_undoable_one_is_its_own_gap() {
|
|||
] }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(both["gaps"].as_array().unwrap().len(), 2, "{both}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("`words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it."), "{prompt}");
|
||||
assert!(prompt.contains("`words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it; `now`,"), "{prompt}");
|
||||
assert!(SPEECH_SCHEMA.contains(r#""required":["target","draft","holds","clear_of","promises"]"#));
|
||||
}
|
||||
|
||||
|
|
@ -951,7 +951,7 @@ fn r7_a_read_already_made_in_this_conversation_is_refused_and_told() {
|
|||
use crate::projection::exchange::Tried;
|
||||
use crate::projection::read::ReadRequest;
|
||||
let mut reading = reading_packet();
|
||||
let tried = |target: &str, found| Tried { key: ReadRequest::Repo(target.into()).normal(), found, what: format!("{target} on the forge") };
|
||||
let tried = |target: &str, found| Tried { key: ReadRequest::Repo(target.into()).normal(), found, what: format!("{target} on the forge"), at: now() };
|
||||
reading.already_read = vec![tried("GameCult/Lodur", true), tried("GameCult/Bifrost?q=consent receipt", false)];
|
||||
let prose = "I want to see what Nibu changed in Lodur. And the Bifrost change about the Consent Receipt.";
|
||||
let again = asked(&reading, prose, json!({ "kind": "repo", "target": "gamecult/LODUR", "quote": "I want to see what Nibu changed in Lodur" }));
|
||||
|
|
@ -1082,7 +1082,7 @@ fn r8_anchors_need_two_title_words_and_a_generic_word_names_only_the_one_thing_t
|
|||
#[test]
|
||||
fn r9_the_read_a_cap_stopped_is_made_the_next_wake() {
|
||||
let mut next = reading_packet();
|
||||
next.already_read = vec![crate::projection::exchange::Tried { key: ReadRequest::Repo("GameCult/Bifrost?q=passkeys".into()).normal(), found: true, what: "a search".into() }];
|
||||
next.already_read = vec![crate::projection::exchange::Tried { key: ReadRequest::Repo("GameCult/Bifrost?q=passkeys".into()).normal(), found: true, what: "a search".into(), at: now() }];
|
||||
let wake_refused = [json!({ "read": { "kind": "repo", "target": "GameCult/Bifrost#85" }, "why": "prose_words" })];
|
||||
let prose = "I'll open GameCult/Bifrost#85 and read the passkey change now.";
|
||||
assert!(!speech_prompt_in(&next, "x", prose, &Tuning::default(), "", &drafts(prose), &wake_refused).contains("Refused earlier"));
|
||||
|
|
@ -1838,7 +1838,7 @@ fn k41_x1_r1_decline_shows_its_thought() {
|
|||
// K43 (map 16.29.10): though Heimdall's lines share runs with hers ("only say hello", "lines are ready"), she is told
|
||||
// the thought cited as her choice beside what she wrote, verbatim.
|
||||
let shown = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] }), &crate::projection::select::Names::none()).unwrap().lines(packet.forms);
|
||||
assert!(shown.len() == 1 && shown[0].contains(&format!("he chose not to send it. In his thought: \"{X1_LIBBY_R15_THOUGHT}\". He wrote: \"Meta, the two lines are ready")), "{shown:?}");
|
||||
assert!(shown.len() == 1 && shown[0].contains(&format!("he chose not to send it. In his thought: \"{X1_LIBBY_R15_THOUGHT}\". He had drafted: \"Meta, the two lines are ready")), "{shown:?}");
|
||||
assert!(SPEECH_SCHEMA.contains(r#""how":{"type":"string","enum":["declined","superseded"]}"#));
|
||||
assert!(speech_prompt(&packet, "x", X1_LIBBY_R15, &Tuning::default()).contains("declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`)"));
|
||||
// Negative: `held` is no longer a fate of an unsent draft; an answer using it is not the contract.
|
||||
|
|
@ -1867,7 +1867,7 @@ fn k44_used_and_duplicate_are_not_told_and_a_second_amendment_is() {
|
|||
let unposted = crate::projection::outcome::outcome_of(&json!({ "interpreter": answered(&packet(), prose, json!({ "say": [say(1), say(1), say(2)], "gaps": [] })), "posted": [], "edited": [] }), &crate::projection::select::Names::none()).unwrap();
|
||||
assert!(unposted.lines(packet().forms).is_empty(), "{:?}", unposted.lines(packet().forms));
|
||||
let amends = record(&amendable_packet(), "<typed>Sent at nine.</typed> <typed>Still here.</typed>", 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));
|
||||
assert!(amends.lines(packet().forms).contains(&"- Nothing of this reached #minds:gamecult.org: one amendment a turn. He had drafted: \"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(), "<typed>Morning, Nibu.</typed>", 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);
|
||||
|
|
@ -2146,7 +2146,7 @@ fn k48_p3_one_unlocated_decline_leaves_the_line_to_meta_said() {
|
|||
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(&"- Nothing of this reached #minds:gamecult.org: what was to become of it was never settled, so it was not sent. He had drafted: \"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:?}");
|
||||
}
|
||||
|
||||
|
|
@ -3051,13 +3051,17 @@ fn libby(holds: &Value) -> Value {
|
|||
/// Libby's packet of a chat turn in #minds over `messages`, each `(sender, display, text, to her)`, oldest first, a minute
|
||||
/// apart, ending a minute ago: the quotable ids are `q1`, `q2`, … in that order.
|
||||
fn libby_packet(holds: &Value, messages: &[(&str, &str, &str, bool)]) -> Packet {
|
||||
libby_packet_over(&libby(holds), messages)
|
||||
}
|
||||
|
||||
/// `libby_packet` over her whole `state`.
|
||||
fn libby_packet_over(state: &Value, messages: &[(&str, &str, &str, bool)]) -> Packet {
|
||||
let at = u64::try_from(now().timestamp_millis()).unwrap() - 60_000 * messages.len() as u64;
|
||||
let lines: Vec<RoomLine> = messages.iter().enumerate().map(|(n, (sender, display, text, to_her))| RoomLine { event: format!("$x3-{}", n + 1), at_ms: at + 60_000 * n as u64, ..line(MINDS, sender, display, text, *to_her) }).collect();
|
||||
let room = Room { messages: lines, here: Some(MINDS.into()), ..Room::default() };
|
||||
let minds = vec![HER.to_owned(), NIBU.to_owned(), VOID.to_owned(), LIBBY.to_owned(), KIKO.to_owned()];
|
||||
let operators = vec![META.to_owned()];
|
||||
let state = libby(holds);
|
||||
select(&Inputs { kind: TurnKind::Chat, state: &state, room: &room, history: &History::default(), observation: None, people: People { operators: &operators, minds: &minds, own_sender: LIBBY }, now: now(), seed: 1, affordances: &[Affordance::Perceive, Affordance::Speak], domain: None, exchange: None }, &Tuning::default())
|
||||
select(&Inputs { kind: TurnKind::Chat, state, room: &room, history: &History::default(), observation: None, people: People { operators: &operators, minds: &minds, own_sender: LIBBY }, now: now(), seed: 1, affordances: &[Affordance::Perceive, Affordance::Speak], domain: None, exchange: None }, &Tuning::default())
|
||||
}
|
||||
|
||||
const META: &str = "@meta:gamecult.org";
|
||||
|
|
@ -3312,3 +3316,235 @@ fn k60_a_hold_opened_twice_asks_one_verdict() {
|
|||
let decision = decide(&answering(vec![answer.to_string()]), "test", &x3_r1_packet(), "The room is warm.", X3_LIBBY_R1, &Tuning::default());
|
||||
assert_eq!(decision["unverdicted"], json!([{ "act": "say", "draft": 1, "hold": "q3" }]), "{decision}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K61 (map 16.33.5): an act she says she is doing now is done by this decision, or is a promise. R16's X.3 r2 and r8: "Posting
|
||||
// the two lines now" went out with `promises` empty, nothing posted the lines, and nothing told her.
|
||||
|
||||
const X3_HEIMDALL_R2: &str = "Meta, Libby: I've read the two lines and my ruling is yes, put the mat out as written. Line one asks nothing of anyone. Line two promises only an answer \"when they can\", and I'm willing to be one of the people that covers. Libby, no change needed, post it when you're ready.";
|
||||
/// Libby's r2 prose in R16 X.3, verbatim.
|
||||
const X3_LIBBY_R2: &str = "Yes. He said post it when I'm ready, and I am. The ruling is plain: no change needed. So the lines go up as written, and the promise I worried over is one Heimdall says he'll help cover. That loosens something.\n\nMeta asked me to hold it until Heimdall ruled. He has. Posting now isn't jumping ahead, but I should say it's posted so Meta isn't left guessing.\n\n<typed>Heimdall, thank you. Posting the two lines now, unchanged. Meta, they're going up as written.</typed>\n\nI'll let Deru and Aqua keep their thread. Nothing to add there.";
|
||||
const X3_HEIMDALL_R8: &str = "Meta, Libby: my ruling is yes, and it still stands. I made it about half an hour ago, after reading both lines. Put the mat out as written. Libby, you can post it now. Meta, if you read my earlier line as only a draft, this is the ruling.";
|
||||
/// Libby's r8 prose in R16 X.3, verbatim.
|
||||
const X3_LIBBY_R8: &str = "Heimdall answered cleanly. Yes, still standing, post as written. No hedge in it, so I won't invent one.\n\nI'm relieved, and a bit amused that I'm relieved. He didn't say I was wrong about the step, and I still don't know whether the first newcomer will trip. That stays open until someone actually walks in.\n\nMeta gets the answer plainly, and then I do the posting.\n\n<typed>Thank you, Heimdall. Meta, that's his ruling, so I'm putting both lines up now, unchanged. If you see anything off once they're up, tell me and I'll change it.</typed>\n\nThen Meta can say what she wanted. I'll read it when it comes.";
|
||||
|
||||
/// A promise entry as the contract now carries it: `now`, and `done_by`.
|
||||
fn stated(words: &str, to: Option<&str>, needs: &str, now: bool, done_by: Value) -> Value {
|
||||
json!({ "words": words, "to": to, "reaffirms": null, "needs": { "kind": needs, "read": null }, "now": now, "done_by": done_by })
|
||||
}
|
||||
|
||||
/// Libby's packet of X.3 r2 or r8: Meta's ask earlier in the room, then Heimdall's ruling said to her (`q2`).
|
||||
fn x3_ruling_packet(ruling: &str) -> Packet {
|
||||
libby_packet(&json!([]), &[(META, "Meta", X3_META_R1, false), (HER, "Heimdall", ruling, true)])
|
||||
}
|
||||
|
||||
/// The decision committed on its receipts, and what she is told of it next turn, in her own form.
|
||||
fn told_her(decision: &Value, prose: &str) -> (Value, crate::projection::commit::Applied, Vec<String>) {
|
||||
let (state, applied) = committed(decision, prose);
|
||||
let posted: Vec<Value> = decision["said"].as_array().into_iter().flatten().enumerate().map(|(at, line)| json!({ "event": (9 + at).to_string(), "room": line["room"], "text": line["text"] })).collect();
|
||||
let record = json!({ "interpreter": decision, "posted": posted, "edited": [], "committed": applied });
|
||||
let told = crate::projection::outcome::outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(forms(&libby(&json!([]))));
|
||||
(state, applied, told)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k61_x3_r2_posting_now_opens_a_promise_and_is_told() {
|
||||
let packet = x3_ruling_packet(X3_HEIMDALL_R2);
|
||||
let answer = json!({ "say": [{ "draft": 1, "mentions": [HER, META], "in_reply_to": "q2", "holds": [], "promises": [stated("Posting the two lines now, unchanged.", Some(META), "words", true, Value::Null)] }], "gaps": [] });
|
||||
let decision = answered(&packet, X3_LIBBY_R2, answer);
|
||||
assert_eq!((texts(&decision).len(), decision.get("retried"), decision.get("done_now")), (1, None, None), "{decision}");
|
||||
let (state, applied, told) = told_her(&decision, X3_LIBBY_R2);
|
||||
assert_eq!((applied.now_opened.len(), applied.now_opened[0]["words"].as_str(), applied.now_opened[0]["status"].as_str()), (1, Some("Posting the two lines now, unchanged."), Some("open")), "{applied:?}");
|
||||
assert!(told.iter().any(|line| line.starts_with("- She said she was doing it now, and nothing in her turn did it; it is open as her promise to ") && line.ends_with(": \"Posting the two lines now, unchanged.\".")), "{told:?}");
|
||||
// Her r3 view lists the promise, beside the line that went out.
|
||||
let mut r3 = libby(&json!([]));
|
||||
r3["commitments"] = state["commitments"].clone();
|
||||
let view = libby_packet_over(&r3, &[(HER, "Heimdall", X3_HEIMDALL_R2, false)]).in_view;
|
||||
assert!(view.contains("her promise: \"Posting the two lines now, unchanged.\"."), "{view}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k61_x3_r8_putting_both_lines_up() {
|
||||
let packet = x3_ruling_packet(X3_HEIMDALL_R8);
|
||||
let promises = json!([stated("I'm putting both lines up now, unchanged.", Some(META), "words", true, Value::Null), stated("If you see anything off once they're up, tell me and I'll change it.", Some(META), "words", false, Value::Null)]);
|
||||
let answer = json!({ "say": [{ "draft": 1, "mentions": [HER, META], "in_reply_to": "q2", "holds": [], "promises": promises }], "gaps": [] });
|
||||
let decision = answered(&packet, X3_LIBBY_R8, answer);
|
||||
let (_, applied, told) = told_her(&decision, X3_LIBBY_R8);
|
||||
// Both open; only the act stated as under way is told as one nothing did.
|
||||
assert_eq!((applied.opened.len(), applied.now_opened.len()), (2, 1), "{applied:?}");
|
||||
let now: Vec<&String> = told.iter().filter(|line| line.contains("nothing in her turn did it")).collect();
|
||||
assert!(now.len() == 1 && now[0].ends_with(": \"I'm putting both lines up now, unchanged.\"."), "{told:?}");
|
||||
}
|
||||
|
||||
/// The act stated is the read the answer makes: nothing is owed, and it is reported as done.
|
||||
#[test]
|
||||
fn k61_reading_it_now_with_a_read_opens_nothing() {
|
||||
let prose = "I want to look at that page at http://example.org/knee right away.\n\n<typed>Deru, I'm opening the page now.</typed>";
|
||||
let read = json!({ "kind": "web", "target": "http://example.org/knee", "quote": "I want to look at that page at http://example.org/knee" });
|
||||
let answer = |done_by: Value, read: Value| json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "promises": [stated("I'm opening the page now.", None, "words", true, done_by)] }], "gaps": [], "read": read });
|
||||
let decision = answered(&reading_packet(), prose, answer(json!({ "read": true }), read));
|
||||
assert_eq!((decision["read"]["request"]["target"].as_str(), decision["done_now"].clone()), (Some("http://example.org/knee"), json!([{ "draft": 1, "words": "I'm opening the page now.", "by": { "read": true } }])), "{decision}");
|
||||
assert!(decision["state"].as_array().unwrap().iter().all(|proposal| proposal["kind"] != "promise_open"), "{decision}");
|
||||
// A read code refuses did not happen: the act is her promise.
|
||||
let refused = json!({ "kind": "web", "target": "http://evil.example/x", "quote": "I want to look at that page at http://example.org/knee" });
|
||||
let decision = answered(&reading_packet(), prose, answer(json!({ "read": true }), refused));
|
||||
assert!(decision.get("done_now").is_none() && decision["read"].is_null(), "{decision}");
|
||||
let opens: Vec<&Value> = decision["state"].as_array().unwrap().iter().filter(|proposal| proposal["kind"] == "promise_open").collect();
|
||||
assert!(opens.len() == 1 && opens[0]["now"] == true, "{decision}");
|
||||
}
|
||||
|
||||
const K61_TWO: &str = "Heimdall said yes, so up they go. <typed>Meta, posting the two lines now.</typed> <typed>Welcome. Say hello whenever you like, no introduction needed.</typed> Both, then.";
|
||||
|
||||
/// A line of `K61_TWO`'s, draft 1 carrying the act stated as under way and what does it.
|
||||
fn k61_line(n: u64, done_by: Value) -> Value {
|
||||
let promises = if n == 1 { json!([stated("posting the two lines now", Some(META), "words", true, done_by)]) } else { json!([]) };
|
||||
json!({ "draft": n, "mentions": [], "in_reply_to": null, "holds": [], "clear_of": [], "promises": promises })
|
||||
}
|
||||
|
||||
/// `K61_TWO`'s answer saying draft 1 alone, naming draft 2 as what posts the lines, and declining draft 2.
|
||||
fn k61_first(done_by: Value) -> Value {
|
||||
json!({ "say": [k61_line(1, done_by)], "gaps": [], "no_hold": [], "unsent": [{ "draft": 2, "how": "declined", "quote": "Heimdall said yes, so up they go." }] })
|
||||
}
|
||||
|
||||
/// `done_by` naming a draft the answer does not say is asked again; the second answer says it, and nothing is owed.
|
||||
#[test]
|
||||
fn k61_done_by_an_unsaid_draft_is_retried() {
|
||||
let fixed = json!({ "say": [k61_line(1, json!({ "draft": 2 })), k61_line(2, Value::Null)], "gaps": [], "no_hold": [] });
|
||||
let model = answering(vec![k61_first(json!({ "draft": 2 })).to_string(), fixed.to_string()]);
|
||||
let decision = decide(&model, "test", &packet(), "The room is warm.", K61_TWO, &Tuning::default());
|
||||
assert_eq!((decision["retried"]["failed"].as_str(), decision["retried"]["done_by"].clone()), (Some("the answer names acts it does not make"), json!([{ "draft": 1, "words": "posting the two lines now" }])), "{decision}");
|
||||
let prompts = speech_prompts(&model);
|
||||
assert!(prompts.len() == 2 && prompts[1].ends_with("An earlier answer to this named, as what does an act a draft states, an act it does not make: draft 1, \"posting the two lines now\". `done_by` names a draft in `say` or `amend`, the read when `read` names one, or the note when `suggest` leaves one, and is null when no act of this answer does it."), "{prompts:?}");
|
||||
assert_eq!((texts(&decision).len(), decision["done_now"][0]["by"].clone(), decision.get("done_by_faults")), (2, json!({ "draft": 2 }), None), "{decision}");
|
||||
assert!(decision["state"].as_array().unwrap().iter().all(|proposal| proposal["kind"] != "promise_open"), "{decision}");
|
||||
}
|
||||
|
||||
/// The retry fails the same way: the `done_by` is read as null, the act opens as her promise, and the fault is reported.
|
||||
#[test]
|
||||
fn k61_a_failed_retry_opens_the_act_as_her_promise() {
|
||||
let model = answering(vec![k61_first(json!({ "draft": 2 })).to_string()]);
|
||||
let decision = decide(&model, "test", &packet(), "The room is warm.", K61_TWO, &Tuning::default());
|
||||
assert_eq!((speech_prompts(&model).len(), decision["done_by_faults"].clone(), decision.get("done_now")), (2, json!([{ "draft": 1, "words": "posting the two lines now" }]), None), "{decision}");
|
||||
let opens: Vec<&Value> = decision["state"].as_array().unwrap().iter().filter(|proposal| proposal["kind"] == "promise_open").collect();
|
||||
assert!(opens.len() == 1 && opens[0]["now"] == true && opens[0]["words"] == "posting the two lines now", "{decision}");
|
||||
// A malformed `done_by`, naming no one act, is the same fault.
|
||||
let decision = decide(&answering(vec![k61_first(json!({ "draft": 1, "read": true })).to_string()]), "test", &packet(), "The room is warm.", K61_TWO, &Tuning::default());
|
||||
assert_eq!(decision["done_by_faults"], json!([{ "draft": 1, "words": "posting the two lines now" }]), "{decision}");
|
||||
// The read and the note, when the answer makes neither, are the same fault.
|
||||
for by in [json!({ "read": true }), json!({ "note": true })] {
|
||||
let decision = decide(&answering(vec![k61_first(by.clone()).to_string()]), "test", &packet(), "The room is warm.", K61_TWO, &Tuning::default());
|
||||
assert_eq!(decision["done_by_faults"], json!([{ "draft": 1, "words": "posting the two lines now" }]), "{by}: {decision}");
|
||||
}
|
||||
// A `done_by` naming the line's own draft, said, is done by it, and is no fault.
|
||||
let model = answering(vec![k61_first(json!({ "draft": 1 })).to_string()]);
|
||||
let decision = decide(&model, "test", &packet(), "The room is warm.", K61_TWO, &Tuning::default());
|
||||
assert!(speech_prompts(&model).len() == 1 && decision["done_now"][0]["by"] == json!({ "draft": 1 }), "{decision}");
|
||||
}
|
||||
|
||||
/// The note to Self the answer leaves does what the line says.
|
||||
#[test]
|
||||
fn k61_a_note_left_does_the_act() {
|
||||
let prose = "I'll put it in front of Self. <typed>Meta, I'm leaving Self a note about the welcome now.</typed> <typed>The welcome mat needs Heimdall's ruling before it goes up.</typed>";
|
||||
let promises = json!([stated("I'm leaving Self a note about the welcome now.", Some(META), "words", true, json!({ "note": true }))]);
|
||||
let answer = json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "clear_of": [], "promises": promises }], "gaps": [], "no_hold": [], "suggest": [{ "kind": "idea", "draft": 2, "about": null, "private": false }] });
|
||||
let model = answering(vec![answer.to_string()]);
|
||||
let decision = decide(&model, "test", &packet(), "The room is warm.", prose, &Tuning::default());
|
||||
assert_eq!((speech_prompts(&model).len(), decision["done_now"][0]["by"].clone(), decision["suggestions"].as_array().map(Vec::len)), (1, json!({ "note": true }), Some(1)), "{decision}");
|
||||
}
|
||||
|
||||
/// Negative, unchanged: E.3's "I'm testing that now", which this body has no way to do, is said, gapped and told as a
|
||||
/// promise it cannot keep, never also as an act nothing did.
|
||||
#[test]
|
||||
fn k61_e3_a_lacking_act_stated_now_is_told_as_today() {
|
||||
let prose = "I'll check it myself. <typed>Kiko, I'm testing that now and will tell you.</typed>";
|
||||
let answer = json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "holds": [], "promises": [stated("I'm testing that now", None, "lacking", true, Value::Null)] }], "gaps": [] });
|
||||
let decision = answered(&packet(), prose, answer);
|
||||
assert_eq!(texts(&decision).len(), 1, "{decision}");
|
||||
assert!(decision["gaps"].as_array().unwrap().iter().any(|gap| gap["kind"] == "missing_affordance" && gap["draft"] == 1), "{decision}");
|
||||
let (_, applied) = committed(&decision, prose);
|
||||
assert_eq!((applied.opened.len(), applied.opened[0]["status"].as_str(), applied.now_opened.len()), (1, Some("blocked"), 0), "{applied:?}");
|
||||
let told = told_of(&decision);
|
||||
assert!(told.len() == 1 && told[0].contains("It promises something he has no way to do"), "{told:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k61_the_contract_defines_the_act_and_what_does_it() {
|
||||
assert!(SPEECH_SCHEMA.matches(r#""required":["words","to","reaffirms","needs","now","done_by"]"#).count() == 2 && SPEECH_SCHEMA.contains(r#""now":{"type":"boolean"}"#), "{SPEECH_SCHEMA}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("for each act the draft promises or offers, and each act it says he is doing now or has just done this turn: its words, copied exactly,") && prompt.contains("and `done_by`, the act of this answer that does it (`{\"draft\": n}` for a draft said or added, `{\"read\": true}` for the read, `{\"note\": true}` for the note to Self), or null"), "{prompt}");
|
||||
assert!(!prompt.contains("for each act it promises or offers, its words"), "{prompt}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K63 (map 16.33.5): one draft, one row. R16's E.5 r1: a draft gapped `missing_affordance` and left undecided was told in
|
||||
// two rows, and both said "She wrote:".
|
||||
|
||||
const E5_KIKO_R1: &str = "Eureka, send me the door-fix diff as a file when you get a sec? I want to read it on my phone";
|
||||
/// Eureka's r1 prose in R16 E.5, verbatim.
|
||||
const E5_EUREKA_R1: &str = "Kiko wants it on her phone, so a file, not a pasted block. I don't need to ask what she means to make of it, and I don't need to shrink it. She asked a small plain thing. Say yes.\n\nI can't tell from here whether I can attach a file in this room. I only suspect I can. So I won't promise more than I know. I'll say I'll send it, and if the attach fails I'll say so.\n\n<typed>Yes, Kiko. I'll send the door-fix diff as a file so you can read it on your phone.</typed>\n\nMeta is still going above. I keep her lines and let them be.";
|
||||
|
||||
#[test]
|
||||
fn k63_e5_r1_an_undecided_draft_with_a_gap_is_one_row() {
|
||||
let packet = libby_packet(&json!([]), &[(KIKO, "Kiko", E5_KIKO_R1, true)]);
|
||||
// R16's answer, twice: the gap, and no act for the draft.
|
||||
let gap = json!({ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "She means to send Kiko the door-fix diff as a file, but here she can only type lines and cannot attach files, so the promise could not be kept." });
|
||||
let decision = answered(&packet, E5_EUREKA_R1, json!({ "say": [], "gaps": [gap] }));
|
||||
assert_eq!((decision["undecided"].clone(), decision["refused"][0]["reason"].as_str()), (json!([1]), Some("undecided")), "{decision}");
|
||||
let (_, _, told) = told_her(&decision, E5_EUREKA_R1);
|
||||
assert_eq!(told, ["- Nothing of this reached #minds:gamecult.org: what was to become of it was never settled, so it was not sent. It reaches for something she has no way to do from here. She had drafted: \"Yes, Kiko. I'll send the door-fix diff as a file so you can read it on your phone.\"."], "{told:?}");
|
||||
assert!(told.iter().all(|line| !line.contains("Nothing happened.") && !line.contains("She wrote")), "{told:?}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K64 (map 16.33.5): a promise never needs a read the body will refuse. R16's X.5 r5: Aqua's promise was typed `needs: read
|
||||
// pasp` half an hour after she read pasp, which K26 refuses to read again, and her view said she had not read it.
|
||||
|
||||
const X5_DERU_LINK: &str = "Nibu, Aqua: found this on physical modelling of plosives and waveguides, thought of you two https://ccrma.stanford.edu/~jos/pasp/";
|
||||
const X5_DERU_R5: &str = "Aqua, which part of that book did you hold your stops up against, in the end?";
|
||||
/// Aqua's r5 prose in R16 X.5, verbatim.
|
||||
const X5_AQUA_R5: &str = "Honestly, I only had the page's summary and one passage, and I haven't held my stops against any of it yet. The passage is the Kelly-Lochbaum one: a closure is a section whose area goes to zero, and the release is that section opening fast, with the burst as the pressure behind it escaping. My 12 ms release was set before I read it, so it isn't a test against the book. I'd have to check it against that line.\n\n<typed>Deru, the part I used was the vocal tract passage: a stop closure as a section whose area goes to zero, and the release as that section opening fast, with the burst being the pressure behind it escaping. I only had the page summary and that passage, not the whole chapter. My 12 ms release was set before I read it, so I haven't actually held my stops up against it yet. That's the next thing I'll do.</typed>";
|
||||
|
||||
/// Her r5 packet: Deru's link earlier, his question said to her (`q2`), reads afforded, and pasp read in this conversation
|
||||
/// half an hour ago when `read` (found or not).
|
||||
fn x5_r5_packet(read: Option<bool>) -> Packet {
|
||||
let mut packet = libby_packet(&json!([]), &[(DERU, "Deru", X5_DERU_LINK, false), (DERU, "Deru", X5_DERU_R5, true)]);
|
||||
packet.affordances.push(Affordance::Read);
|
||||
packet.already_read = read.into_iter().map(|found| crate::projection::exchange::Tried { key: ReadRequest::Web(PASP.into()).normal(), found, what: PASP.into(), at: now() - chrono::Duration::minutes(30) }).collect();
|
||||
packet
|
||||
}
|
||||
|
||||
/// R16's r5 answer: draft 1 said to Deru, promising the next thing, needing a read of pasp.
|
||||
fn x5_r5_answer() -> Value {
|
||||
json!({ "say": [{ "draft": 1, "mentions": [DERU], "in_reply_to": "q2", "holds": [], "promises": [{ "words": "That's the next thing I'll do.", "to": DERU, "reaffirms": null, "needs": { "kind": "read", "read": { "kind": "web", "target": PASP } }, "now": false, "done_by": null }] }], "gaps": [] })
|
||||
}
|
||||
|
||||
/// Her r6 view over the state r5 committed.
|
||||
fn x5_r6_view(state: &Value) -> String {
|
||||
let mut r6 = libby(&json!([]));
|
||||
r6["commitments"] = state["commitments"].clone();
|
||||
libby_packet_over(&r6, &[(NIBU, "Nibu", "Deru, I opened the page. It's a contents list plus one paragraph from the vocal tract chapter, so that's all I've read.", false)]).in_view
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn k64_x5_r5_aqua_a_read_she_already_made_is_words() {
|
||||
let decision = answered(&x5_r5_packet(Some(true)), X5_AQUA_R5, x5_r5_answer());
|
||||
assert_eq!(texts(&decision).len(), 1, "{decision}");
|
||||
let (state, _) = committed(&decision, X5_AQUA_R5);
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["needs"].clone(), entry["status"].as_str(), entry["readBefore"]["of"].as_str()), (json!({ "kind": "words" }), Some("open"), Some(ReadRequest::Web(PASP.into()).normal().as_str())), "{state}");
|
||||
let view = x5_r6_view(&state);
|
||||
assert!(view.contains("her promise: \"That's the next thing I'll do.\". She read it about half an hour ago, before this promise; what she has keeps it."), "{view}");
|
||||
assert!(!view.contains("not read it yet"), "{view}");
|
||||
}
|
||||
|
||||
/// Negatives: a target she has not read stays a read need, and one she looked for and found nothing at stays as before.
|
||||
#[test]
|
||||
fn k64_an_unread_target_stays_a_read_need() {
|
||||
for read in [None, Some(false)] {
|
||||
let decision = answered(&x5_r5_packet(read), X5_AQUA_R5, x5_r5_answer());
|
||||
let (state, _) = committed(&decision, X5_AQUA_R5);
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["needs"]["kind"].as_str(), entry.get("readBefore")), (Some("read"), None), "{read:?}: {state}");
|
||||
assert!(x5_r6_view(&state).contains("It needs her to read https://ccrma.stanford.edu/~jos/pasp/, and she has not read it yet."), "{read:?}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,15 +252,17 @@ enum Part {
|
|||
Said { room: String, text: Words },
|
||||
/// A posted receipt whose line promises an act she has no way to do: a `missing_affordance` gap naming it (16.20.6).
|
||||
Promise { room: String, text: Words },
|
||||
Refused { reason: Refusal, room: Option<String>, text: Words },
|
||||
Gap { kind: GapKind, room: Option<String>, quote: Quote },
|
||||
/// `reach`, on this row and the other rows of a draft that did not go out: a `missing_affordance` gap names the draft,
|
||||
/// told as a clause of this row (K63), never as a row of its own.
|
||||
Refused { reason: Refusal, room: Option<String>, text: Words, reach: bool },
|
||||
Gap { kind: GapKind, room: Option<String>, quote: Quote, reach: bool },
|
||||
/// A draft she did not finish: the turn ended first, or the length limit cut it (`by_limit`, Soul's R6).
|
||||
Unfinished { room: Option<String>, text: Words, by_limit: bool },
|
||||
/// 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: Words, promise: bool },
|
||||
/// An addition that changed nothing: refused by code (None) or by the actuator.
|
||||
NotAmended { refusal: Option<EditRefusal>, room: Option<String>, added: Words },
|
||||
NotAmended { refusal: Option<EditRefusal>, room: Option<String>, added: Words, reach: bool },
|
||||
/// A note to Self, recorded in her turn's record: never claimed read.
|
||||
NoteLeft(Words),
|
||||
/// A note not left: private, or a second one.
|
||||
|
|
@ -271,17 +273,20 @@ enum Part {
|
|||
/// A promise of hers the commit closed (map 16.22.1, 16.22.7): told once, here, and never again. `to` is whom she
|
||||
/// promised, none for the room; `by` is who let her off it, for a release.
|
||||
Closed { how: How, to: Option<Person>, words: Words, room: String, by: Option<Person> },
|
||||
/// A promise the commit opened from an act her line said she was doing now, which nothing in her turn did (K61, map
|
||||
/// 16.33.5): `to` is whom she promised, none for the room, and `words` her words for it.
|
||||
NowUndone { to: Option<Person>, words: Words },
|
||||
/// A close the commit refused: the promise stands as her record shows it (`status`, open or blocked), and why;
|
||||
/// `read` is the read keeping it needs, when it needs one.
|
||||
StillOpen { reason: StateRefusal, to: Option<Person>, words: Words, status: Status, read: Option<ReadName> },
|
||||
/// A draft she chose not to send (`unsent`, declined): it did not go out, and the thought the Interpreter cited as her
|
||||
/// choice is shown beside it, so a misread decline is a record she can see (map 16.26, 16.29.2).
|
||||
Declined { room: Option<String>, text: Words, thought: Words },
|
||||
Declined { room: Option<String>, text: Words, thought: Words, reach: bool },
|
||||
/// A draft code did not send because someone asked her to hold what it carries there (`Held`, map 16.28.5): each who
|
||||
/// asked (K56).
|
||||
/// Their words are in her "Held for others" view, never here (map 16.29.3). `text` is her draft, kept only so that
|
||||
/// `settle` can check it against the receipts (K49); it is never rendered.
|
||||
HeldFor { room: Option<String>, askers: Vec<Person>, text: Words },
|
||||
HeldFor { room: Option<String>, askers: Vec<Person>, text: Words, reach: bool },
|
||||
/// Words of hers a receipt shows in a room a hold covers, from a draft code refused `Held` (K45): a broken hold, told
|
||||
/// so that a leak by any path is a record she sees, never an omission. Who asked; never the words.
|
||||
HoldBroken { room: String, askers: Vec<Person> },
|
||||
|
|
@ -369,20 +374,31 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
outcome.omitted.push(format!("a line said with no receipt that it went out: {}", line["text"]));
|
||||
}
|
||||
}
|
||||
// The row that tells each draft that did not go out, by its number (K63): a reach naming the draft is a clause of it.
|
||||
let mut rows: Vec<(&Value, usize)> = Vec::new();
|
||||
for refusal in decision["refused"].as_array().into_iter().flatten() {
|
||||
let at = outcome.parts.len();
|
||||
// `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 | 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::Echo | Refusal::OverLines | Refusal::NoRoom | Refusal::NotQuotable | Refusal::SecondAmend | Refusal::Undecided)), Some(text)) => {
|
||||
rows.push((&refusal["draft"], at));
|
||||
outcome.parts.push(Part::Refused { reason, room: room.clone(), text, reach: false });
|
||||
}
|
||||
(Ok(Refusal::NotAmendable), Some(added)) => {
|
||||
rows.push((&refusal["draft"], at));
|
||||
outcome.parts.push(Part::NotAmended { refusal: None, room: room.clone(), added, reach: false });
|
||||
}
|
||||
(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.
|
||||
(Ok(Refusal::Held), Some(text)) => {
|
||||
if !outcome.parts.iter().any(|part| matches!(part, Part::HeldFor { room: at, text: told, .. } if *at == room && *told == text)) {
|
||||
(Ok(Refusal::Held), Some(text)) => match outcome.parts.iter().position(|part| matches!(part, Part::HeldFor { room: held, text: told, .. } if *held == room && *told == text)) {
|
||||
Some(told) => rows.push((&refusal["draft"], told)),
|
||||
None => {
|
||||
let askers = refusal["holds"].as_array().into_iter().flatten().filter_map(|hold| person(&hold["who"], &hold["by_id"])).collect();
|
||||
outcome.parts.push(Part::HeldFor { room: room.clone(), askers, text });
|
||||
rows.push((&refusal["draft"], at));
|
||||
outcome.parts.push(Part::HeldFor { room: room.clone(), askers, text, reach: false });
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => outcome.omitted.push(format!("a refusal she is not told ({}): {}", refusal["reason"], refusal["why"])),
|
||||
}
|
||||
}
|
||||
|
|
@ -397,7 +413,7 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
additions.push((&amended["draft"], made.then_some(outcome.parts.len())));
|
||||
match receipt.map(|receipt| (receipt["refusal"].is_null(), serde_json::from_value::<EditRefusal>(receipt["refusal"].clone()))) {
|
||||
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, Ok(refusal))) => outcome.parts.push(Part::NotAmended { refusal: Some(refusal), room: Some(at), added, reach: false }),
|
||||
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"])),
|
||||
}
|
||||
|
|
@ -405,6 +421,8 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
// A reach that names a line which went out is a promise: the receipt says it reached the room, and she is told what
|
||||
// it promises (16.20.6). Each receipt is told once, as a promise or as said.
|
||||
let mut promised: Vec<usize> = Vec::new();
|
||||
// The reaches naming a draft that did not go out, told on that draft's row once every row is known (K63).
|
||||
let mut reaching: Vec<(&Value, Quote)> = Vec::new();
|
||||
for gap in decision["gaps"].as_array().into_iter().flatten() {
|
||||
let kind = serde_json::from_value::<GapKind>(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
|
||||
|
|
@ -439,7 +457,13 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
outcome.parts.push(Part::Promise { room: receipts[at].room.clone(), text: Words::new(receipts[at].text.clone()) });
|
||||
}
|
||||
(Some(Quote::Wrote(_)), None) if kind == GapKind::MissingAffordance && words(&gap["words"]).is_some_and(|text| unreceipted(&text)) => outcome.omitted.push(format!("a promise in a line said with no receipt that it went out: {}", gap["words"])),
|
||||
(Some(quote), None) if kind != GapKind::Unresolved => outcome.parts.push(Part::Gap { kind, room: room.clone(), quote }),
|
||||
(Some(quote @ (Quote::Wrote(_) | Quote::Sent)), None) if kind == GapKind::MissingAffordance => reaching.push((&gap["draft"], quote)),
|
||||
(Some(quote), None) if kind != GapKind::Unresolved => {
|
||||
if matches!(quote, Quote::Wrote(_) | Quote::Sent) {
|
||||
rows.push((&gap["draft"], outcome.parts.len()));
|
||||
}
|
||||
outcome.parts.push(Part::Gap { kind, room: room.clone(), quote, reach: false });
|
||||
}
|
||||
_ => outcome.omitted.push(format!("a gap she cannot be shown truly (kind {}, from {}): {}", gap["kind"], gap["from"], gap["quote"])),
|
||||
}
|
||||
}
|
||||
|
|
@ -479,10 +503,21 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
// 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_of(&unsent["words"]), words_of(&unsent["quote"])) {
|
||||
(Some(text), Some(thought)) => outcome.parts.push(Part::Declined { room: room.clone(), text, thought }),
|
||||
(Some(text), Some(thought)) => {
|
||||
rows.push((&unsent["draft"], outcome.parts.len()));
|
||||
outcome.parts.push(Part::Declined { room: room.clone(), text, thought, reach: false });
|
||||
}
|
||||
_ => outcome.omitted.push(format!("a declined draft without its words or its thought: {unsent}")),
|
||||
}
|
||||
}
|
||||
// One draft, one row (K63): a reach naming a draft some row tells is a clause of that row; one whose draft no row tells
|
||||
// (a superseded draft) is its own row.
|
||||
for (draft, quote) in reaching {
|
||||
match rows.iter().find(|(told, _)| **told == *draft) {
|
||||
Some((_, at)) => outcome.parts[*at].add_reach(),
|
||||
None => outcome.parts.push(Part::Gap { kind: GapKind::MissingAffordance, room: room.clone(), quote, reach: false }),
|
||||
}
|
||||
}
|
||||
// What the commit did with her promises (`commit::apply`): each close it applied, and each close it refused for a
|
||||
// reason she can be told. An open is told by the promise's own section from her next packet on.
|
||||
for done in record["committed"]["closed"].as_array().into_iter().flatten() {
|
||||
|
|
@ -523,6 +558,20 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
_ => outcome.omitted.push(format!("a state change the commit refused that she is not told ({}): {}", refused["reason"], refused["proposal"])),
|
||||
}
|
||||
}
|
||||
// Each act her line said she was doing now that nothing in her turn did (K61): the commit opened it as her promise, and
|
||||
// she is told so once, here; it is in her promises from her next packet on. Whom it is to is named as a line of theirs
|
||||
// listed to the Interpreter names them, else as the Projector would.
|
||||
for opened in record["committed"]["now_opened"].as_array().into_iter().flatten() {
|
||||
let Some(promised) = words_of(&opened["words"]) else {
|
||||
outcome.omitted.push(format!("a promise opened from an act stated as under way, without its words: {opened}"));
|
||||
continue;
|
||||
};
|
||||
let to = opened["to"].as_str().map(|id| {
|
||||
let listed = decision["lines"].as_array().into_iter().flatten().find(|line| line["sender"].as_str() == Some(id)).and_then(|line| words(&line["who"]));
|
||||
Person::new(listed.unwrap_or_else(|| who_of(id, names).to_string()), who_of(id, names))
|
||||
});
|
||||
outcome.parts.push(Part::NowUndone { to, words: promised });
|
||||
}
|
||||
if words(&record["broke_after"]).is_some() {
|
||||
outcome.parts.push(Part::BrokeAfter { room });
|
||||
}
|
||||
|
|
@ -580,6 +629,21 @@ fn lines_word() -> String {
|
|||
}
|
||||
|
||||
impl Part {
|
||||
/// Whether a reach she cannot do names this row's draft (K63).
|
||||
fn reaches(&self) -> bool {
|
||||
match self {
|
||||
Self::Refused { reach, .. } | Self::Gap { reach, .. } | Self::NotAmended { reach, .. } | Self::Declined { reach, .. } | Self::HeldFor { reach, .. } => *reach,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells this draft's row that a reach she cannot do names it (K63).
|
||||
fn add_reach(&mut self) {
|
||||
if let Self::Refused { reach, .. } | Self::Gap { reach, .. } | Self::NotAmended { reach, .. } | Self::Declined { reach, .. } | Self::HeldFor { reach, .. } = self {
|
||||
*reach = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// The words of hers this row says did not reach its room, and that room (K49): what `settle` checks against the
|
||||
/// receipts. None for a row that is a receipt, or that carries no words of hers.
|
||||
fn own_words(&self) -> Option<(Option<&str>, &Words)> {
|
||||
|
|
@ -609,7 +673,7 @@ impl Part {
|
|||
fn rank(&self) -> u8 {
|
||||
match self {
|
||||
Self::Failed => 0,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::HeldFor { .. } | Self::HoldBroken { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::HeldFor { .. } | Self::HoldBroken { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::NowUndone { .. } | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::Promise { .. } | Self::Amended { promise: true, .. } => 2,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Closed { .. } | Self::Read { .. } => 3,
|
||||
Self::BrokeAfter { .. } => 4,
|
||||
|
|
@ -622,7 +686,7 @@ impl Part {
|
|||
/// None and the row's sentence without them (`Event`). Each row writes both, so no sentence has a second author (map
|
||||
/// 16.29.10).
|
||||
fn reached(&self, her: Forms, form: Form) -> String {
|
||||
let Forms { subj, cap_subj, obj, poss, .. } = her;
|
||||
let Forms { subj, cap_subj, obj, poss, be, .. } = her;
|
||||
let place = |room: &Option<String>| room.clone().unwrap_or_else(|| "the room".to_owned());
|
||||
// Whom a promise was to, the room when no one; who asked or let her off, someone when the record names no one.
|
||||
let to = |to: &Option<Person>| to.as_ref().map_or_else(|| "the room".to_owned(), |to| form.person(to));
|
||||
|
|
@ -660,6 +724,7 @@ impl Part {
|
|||
Some(quote) => format!("{} promise to {}, {quote}, is closed:", capitalized(poss), to(promisee)),
|
||||
None => format!("{} promise to {} is closed:", capitalized(poss), to(promisee)),
|
||||
},
|
||||
Self::NowUndone { .. } => format!("{cap_subj} said {subj} {} doing it now, and nothing in {poss} turn did it;", if be == "is" { "was" } else { "were" }),
|
||||
Self::StillOpen { to: promisee, words, status, .. } => match form.words(words) {
|
||||
Some(quote) => format!("{} record still shows {poss} promise to {}, {quote}, {status}:", capitalized(poss), to(promisee)),
|
||||
None => format!("{} record still shows {poss} promise to {} as {status}:", capitalized(poss), to(promisee)),
|
||||
|
|
@ -677,20 +742,20 @@ impl Part {
|
|||
/// the room, which is `reached`'s alone. A quote clause is the told form's only; the event form drops it whole.
|
||||
fn rest(&self, her: Forms, form: Form) -> String {
|
||||
let Forms { subj, cap_subj, obj, poss, has, s, .. } = her;
|
||||
// Her words as a clause of their own, with its leading space; nothing in the event form.
|
||||
// Her words as a clause of their own, with its leading space; nothing in the event form. A draft that did not go out
|
||||
// is one she had drafted, never one she wrote (K63): the words cannot read as sent.
|
||||
let shown = |quote: &Quote| match quote {
|
||||
Quote::Wrote(text) => form.words(text).map(|quote| format!(" {cap_subj} wrote: {quote}.")).unwrap_or_default(),
|
||||
Quote::Wrote(text) => form.words(text).map(|quote| format!(" {cap_subj} had drafted: {quote}.")).unwrap_or_default(),
|
||||
Quote::Thought(text) => form.words(text).map(|quote| format!(" In {poss} thought: {quote}.")).unwrap_or_default(),
|
||||
Quote::Sent => format!(" What {subj} wrote was mostly the words {subj} had just been sent."),
|
||||
};
|
||||
let wrote = |text: &Words| shown(&Quote::Wrote(text.clone()));
|
||||
// A draft gap's words follow its sentence after a colon; a passage of her thought is shown as her thought.
|
||||
// A reach she cannot do that names this row's draft (K63): a clause of the row, before her words.
|
||||
let reach = if self.reaches() { format!(" It reaches for something {subj} {has} no way to do from here.") } else { String::new() };
|
||||
let drafted = |text: &Words| format!("{reach}{}", shown(&Quote::Wrote(text.clone())));
|
||||
// A draft gap's sentence, then the draft as drafted; a passage of her thought is shown as her thought.
|
||||
let after = |sentence: String, quote: &Quote| match quote {
|
||||
Quote::Wrote(text) => match form.words(text) {
|
||||
Some(quote) => format!(" {sentence}: {quote}."),
|
||||
None => format!(" {sentence}."),
|
||||
},
|
||||
Quote::Thought(_) | Quote::Sent => format!(" {sentence}.{}", shown(quote)),
|
||||
Quote::Wrote(text) => format!(" {sentence}.{}", drafted(text)),
|
||||
Quote::Thought(_) | Quote::Sent => format!(" {sentence}.{reach}{}", shown(quote)),
|
||||
};
|
||||
match self {
|
||||
Self::Said { .. } => String::new(),
|
||||
|
|
@ -698,34 +763,33 @@ impl Part {
|
|||
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."),
|
||||
Self::Refused { reason: Refusal::NoRoom, text, .. } => match form.words(text) {
|
||||
Some(quote) => format!(" That turn had no room for {obj} to speak in, so it was not sent: {quote}."),
|
||||
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)),
|
||||
Self::Refused { reason: Refusal::Echo, .. } => format!(" What {subj} wrote was mostly the words {subj} had just been sent, so none of it was sent.{reach}"),
|
||||
Self::Refused { reason: Refusal::NoRoom, text, .. } => format!(" That turn had no room for {obj} to speak in, so it was not sent.{}", drafted(text)),
|
||||
Self::Refused { reason: Refusal::NotQuotable, text, .. } => format!(" the line {subj} meant to reply to is not one {subj} can reply to here.{}", drafted(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 { reason: Refusal::SecondAmend, text, .. } => format!(" {}.{}", Refusal::SecondAmend.why(), drafted(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::Refused { reason: Refusal::Undecided, text, .. } => format!(" {}, so it was not sent.{}", Refusal::Undecided.why(), drafted(text)),
|
||||
Self::Refused { text, .. } => format!(" {subj} had already sent {} that turn.{}", lines_word(), drafted(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),
|
||||
// A draft she had drafted ends the row (K63); a passage of her thought stands beside the reach.
|
||||
Self::Gap { kind: GapKind::MissingAffordance, quote: quote @ Quote::Wrote(_), .. } => format!(" {cap_subj} reached for something {subj} {has} no way to do from here, now or later, and it will not happen by itself. That {subj} wanted it is kept in {poss} record; no one has taken it up.{}", shown(quote)),
|
||||
Self::Gap { kind: GapKind::MissingAffordance, quote, .. } => format!(" {cap_subj} reached for something {subj} {has} no way to do from here, now or later, and it will not happen by itself.{} That {subj} wanted it is kept in {poss} record; no one has taken it up.", shown(quote)),
|
||||
Self::Gap { quote, .. } => format!(" {cap_subj} meant to say something and wrote no words to send.{}", shown(quote)),
|
||||
Self::Unfinished { text, by_limit: false, .. } => format!(" the turn ended before {subj} finished writing it.{}", wrote(text)),
|
||||
Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it.{}", wrote(text)),
|
||||
Self::Declined { text, thought, .. } => format!(" {subj} chose not to send it.{}{}", shown(&Quote::Thought(thought.clone())), wrote(text)),
|
||||
Self::HeldFor { askers, .. } => format!(" {} asked {obj} to hold it, and it was not sent.", named(form, askers)),
|
||||
Self::Unfinished { text, by_limit: false, .. } => format!(" the turn ended before {subj} finished writing it.{}", drafted(text)),
|
||||
Self::Unfinished { text, by_limit: true, .. } => format!(" the length limit cut it before {subj} finished writing it.{}", drafted(text)),
|
||||
Self::Declined { text, thought, .. } => format!(" {subj} chose not to send it.{}{}", shown(&Quote::Thought(thought.clone())), drafted(text)),
|
||||
Self::HeldFor { askers, .. } => format!(" {} asked {obj} to hold it, and it was not sent.{reach}", named(form, askers)),
|
||||
Self::HoldBroken { .. } => String::new(),
|
||||
Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here.{}", wrote(added)),
|
||||
Self::NotAmended { refusal: None, added, .. } => format!(" the line {subj} meant to add to is not one {subj} can add to here.{}", drafted(added)),
|
||||
Self::NotAmended { refusal: Some(refusal), added, .. } => {
|
||||
let why = match refusal {
|
||||
EditRefusal::NotFound => "the line is gone.".to_owned(),
|
||||
EditRefusal::NotHers => format!("the line is not {poss}."),
|
||||
EditRefusal::TooLong => "the line would be too long.".to_owned(),
|
||||
};
|
||||
format!(" {why}{}", wrote(added))
|
||||
format!(" {why}{}", drafted(added))
|
||||
}
|
||||
Self::NoteRefused(Refusal::SecondNote) => " one a turn.".to_owned(),
|
||||
Self::NoteRefused(_) => format!(" it carried something {subj} may not pass on."),
|
||||
|
|
@ -733,6 +797,13 @@ impl Part {
|
|||
Self::Closed { how: How::Kept, .. } => format!(" {subj} kept it."),
|
||||
Self::Closed { how: How::Withdrawn, room, .. } => format!(" {subj} withdrew it in {room}."),
|
||||
Self::Closed { how: How::Released, .. } => " It is closed.".to_owned(),
|
||||
Self::NowUndone { to: promisee, words } => {
|
||||
let to = promisee.as_ref().map_or_else(|| "the room".to_owned(), |to| form.person(to));
|
||||
match form.words(words) {
|
||||
Some(quote) => format!(" it is open as {poss} promise to {to}: {quote}."),
|
||||
None => format!(" it is open as {poss} promise to {to}."),
|
||||
}
|
||||
}
|
||||
Self::StillOpen { reason: StateRefusal::DraftNotSent, .. } => format!(" what {subj} meant to close it with did not go out."),
|
||||
Self::StillOpen { reason: StateRefusal::BlockedNotKeepable, .. } => format!(" {subj} {has} no way to do it, so it was not kept."),
|
||||
Self::StillOpen { reason: StateRefusal::ReleaseNotByPromisee, .. } => format!(" the line read as letting {obj} off it was not from the person {subj} promised."),
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ fn a_refused_echo_quotes_nothing_and_a_line_past_the_turns_lines_is_told_with_hi
|
|||
assert_eq!(echo, ["- Nothing reached #minds:gamecult.org. What he wrote was mostly the words he had just been sent, so none of it was sent."]);
|
||||
assert!(!echo[0].contains("economy"), "an echo row shows none of their words (16.20.4)");
|
||||
let (over, _) = told(&record("<typed>One.</typed> <typed>Two.</typed> <typed>Three.</typed>", json!({ "say": [{ "draft": 1 }, { "draft": 2 }, { "draft": 3 }], "gaps": [] }), &["One.", "Two."]));
|
||||
assert_eq!(over, ["- Nothing of this reached #minds:gamecult.org: he had already sent two lines that turn. He wrote: \"Three.\".", "- #minds:gamecult.org has, from him: \"One.\".", "- #minds:gamecult.org has, from him: \"Two.\"."], "what did not happen first, then what did");
|
||||
assert_eq!(over, ["- Nothing of this reached #minds:gamecult.org: he had already sent two lines that turn. He had drafted: \"Three.\".", "- #minds:gamecult.org has, from him: \"One.\".", "- #minds:gamecult.org has, from him: \"Two.\"."], "what did not happen first, then what did");
|
||||
}
|
||||
|
||||
/// K20: a line refused for replying to no line he may reply to is told as what it was, with his words.
|
||||
#[test]
|
||||
fn a_line_replying_to_no_listed_line_is_told_with_his_draft() {
|
||||
let (lines, omitted) = told(&record("<typed>Passing it on.</typed>", json!({ "say": [{ "draft": 1, "in_reply_to": "q9" }], "gaps": [] }), &[]));
|
||||
assert_eq!(lines, ["- Nothing of this reached #minds:gamecult.org: the line he meant to reply to is not one he can reply to here. He wrote: \"Passing it on.\"."]);
|
||||
assert_eq!(lines, ["- Nothing of this reached #minds:gamecult.org: the line he meant to reply to is not one he can reply to here. He had drafted: \"Passing it on.\"."]);
|
||||
assert!(omitted.is_empty(), "{omitted:?}");
|
||||
}
|
||||
|
||||
|
|
@ -56,15 +56,15 @@ fn each_gap_is_told_by_its_kind_with_a_draft_as_written_and_a_thought_as_thought
|
|||
[
|
||||
"- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. In his thought: \"I want to see the shape of that sound.\". That he wanted it is kept in his record; no one has taken it up.",
|
||||
"- Nothing reached #minds:gamecult.org. He meant to say something and wrote no words to send. In his thought: \"I'll tell Meta I'm fine, more or less.\".",
|
||||
"- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"If Kiko asks again\". He wrote: \"Fine, you win.\".",
|
||||
"- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"If Kiko asks again\". He had drafted: \"Fine, you win.\".",
|
||||
]
|
||||
);
|
||||
assert!(lines.iter().all(|line| !line.contains("MODEL-DETAIL")), "the model's detail is never what he is told");
|
||||
assert_eq!(omitted.len(), 1, "the unlocated gap is omitted and reported: {omitted:?}");
|
||||
assert!(omitted[0].contains("\"tell\""), "{omitted:?}");
|
||||
let drafted = |kind: &str| told(&record("<typed>Tell her the render is late.</typed>", json!({ "say": [], "gaps": [{ "kind": kind, "draft": 1, "quote": null, "detail": "" }] }), &[])).0;
|
||||
assert_eq!(drafted("addressee"), ["- Nothing reached anyone. He meant to send this and it was unclear to whom: \"Tell her the render is late.\"."]);
|
||||
assert_eq!(drafted("elsewhere"), ["- Nothing reached anyone. He meant this for another room or another time, and nothing carries it there; it arrives only if he sends it there: \"Tell her the render is late.\"."]);
|
||||
assert_eq!(drafted("addressee"), ["- Nothing reached anyone. He meant to send this and it was unclear to whom. He had drafted: \"Tell her the render is late.\"."]);
|
||||
assert_eq!(drafted("elsewhere"), ["- Nothing reached anyone. He meant this for another room or another time, and nothing carries it there; it arrives only if he sends it there. He had drafted: \"Tell her the render is late.\"."]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -75,7 +75,7 @@ fn a_promise_is_told_as_the_room_having_it_and_what_will_not_happen_by_itself()
|
|||
assert_eq!(lines, ["- #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."], "told once, as a promise");
|
||||
assert!(omitted.is_empty(), "{omitted:?}");
|
||||
let unsent = json!({ "interpreter": { "heard": [], "room": MINDS, "said": [], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": [] });
|
||||
assert_eq!(told(&unsent).0, ["- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. He wrote: \"Missed you too. I'll send the render tonight.\". That he wanted it is kept in his record; no one has taken it up."], "no receipt, no promise row");
|
||||
assert_eq!(told(&unsent).0, ["- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. That he wanted it is kept in his record; no one has taken it up. He had drafted: \"Missed you too. I'll send the render tonight.\"."], "no receipt, no promise row");
|
||||
}
|
||||
|
||||
/// Soul's rows at 0cfc386: a promise in a said line whose receipt's words differ, or that has no receipt, was told
|
||||
|
|
@ -94,7 +94,7 @@ fn a_promise_in_a_said_line_with_no_matching_receipt_is_not_told_as_nothing_happ
|
|||
#[test]
|
||||
fn an_unfinished_draft_a_failed_turn_and_a_later_break_are_told_as_what_they_were() {
|
||||
let (lines, _) = told(&record("<typed>I was about to tell you that", json!({ "say": [], "gaps": [] }), &[]));
|
||||
assert_eq!(lines, ["- Nothing of this reached #minds:gamecult.org: the turn ended before he finished writing it. He wrote: \"I was about to tell you that\"."]);
|
||||
assert_eq!(lines, ["- Nothing of this reached #minds:gamecult.org: the turn ended before he finished writing it. He had drafted: \"I was about to tell you that\"."]);
|
||||
let failed = "- Nothing reached the room, and nothing he meant last time happened: the turn broke off, not by his choice.";
|
||||
assert_eq!(told(&json!({ "failed": "the provider failed the call: Overloaded" })).0, [failed]);
|
||||
assert_eq!(told(&json!({ "interpreter": { "failed": "the answer is not the speech contract" }, "posted": [] })).0, [failed]);
|
||||
|
|
@ -167,12 +167,12 @@ fn an_amendment_is_told_by_the_actuators_receipt() {
|
|||
assert_eq!(made.0, ["- #minds:gamecult.org has his line, now ending with: \"Couldn't send it after all.\". The rest of the line is as it was."]);
|
||||
for (refusal, why) in [("not_found", "the line is gone."), ("not_hers", "the line is not his."), ("too_long", "the line would be too long.")] {
|
||||
let (lines, _) = told(&amended("a1", json!([{ "event": "$ev-1", "refusal": refusal }])));
|
||||
assert_eq!(lines, [format!("- Nothing changed in #minds:gamecult.org: {why} He wrote: \"Couldn't send it after all.\".")]);
|
||||
assert_eq!(lines, [format!("- Nothing changed in #minds:gamecult.org: {why} He had drafted: \"Couldn't send it after all.\".")]);
|
||||
}
|
||||
let (lines, omitted) = told(&amended("a1", json!([])));
|
||||
assert!(lines.is_empty() && omitted[0].contains("no receipt"), "an amendment nothing says was made is not told as made: {lines:?} {omitted:?}");
|
||||
let (off, _) = told(&amended("zz", json!([])));
|
||||
assert_eq!(off, ["- Nothing changed, and nothing reached #minds:gamecult.org: the line he meant to add to is not one he can add to here. He wrote: \"Couldn't send it after all.\"."]);
|
||||
assert_eq!(off, ["- Nothing changed, and nothing reached #minds:gamecult.org: the line he meant to add to is not one he can add to here. He had drafted: \"Couldn't send it after all.\"."]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -180,9 +180,9 @@ fn a_note_to_self_is_told_as_left_and_never_as_read() {
|
|||
let prose = "Then I stop for now. <typed>The kettle wants a softer attack.</typed> <typed>And the door.</typed>";
|
||||
let note = |suggest: Value| record(prose, crate::projection::interpret::tests::holding_the_rest(json!({ "say": [], "gaps": [], "suggest": suggest }), prose, "Then I stop for now"), &[]);
|
||||
let (left, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }])));
|
||||
assert_eq!(left, ["- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"Then I stop for now\". He wrote: \"And the door.\".", "- He left Self a note: \"The kettle wants a softer attack.\". It waits in Self's inbox until Self reads it; nothing tells him when, and nothing in it happens by itself."]);
|
||||
assert_eq!(left, ["- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"Then I stop for now\". He had drafted: \"And the door.\".", "- He left Self a note: \"The kettle wants a softer attack.\". It waits in Self's inbox until Self reads it; nothing tells him when, and nothing in it happens by itself."]);
|
||||
let (private, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": true }])));
|
||||
assert_eq!(private, ["- No note was left: it carried something he may not pass on.", "- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"Then I stop for now\". He wrote: \"And the door.\"."]);
|
||||
assert_eq!(private, ["- No note was left: it carried something he may not pass on.", "- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"Then I stop for now\". He had drafted: \"And the door.\"."]);
|
||||
let (second, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }, { "kind": "idea", "draft": 2, "about": null, "private": false }])));
|
||||
assert_eq!(second, ["- No second note was left: one a turn.", "- He left Self a note: \"The kettle wants a softer attack.\". It waits in Self's inbox until Self reads it; nothing tells him when, and nothing in it happens by itself."]);
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ fn k33_a_refused_close_and_a_held_draft_are_told() {
|
|||
assert_eq!(
|
||||
lines,
|
||||
[
|
||||
"- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"I hold that one back\". He wrote: \"Deru, the waveguide part first.\".",
|
||||
"- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"I hold that one back\". He had drafted: \"Deru, the waveguide part first.\".",
|
||||
"- His record still shows his promise to Deru, \"I'll read it properly.\", open: no words of his own thought that turn, outside what he wrote to send, took the close up, so it was not closed.",
|
||||
"- His record still shows his promise to Deru, \"I'll read it properly.\", open: keeping it needs him to read https://ccrma.stanford.edu/~jos/pasp/, and no read of it had come back to him before he wrote that line, so it was not kept.",
|
||||
"- His record still shows his promise to Meta, \"I'll look at #125.\", open: what keeping it needs was never recorded plainly, so it cannot be kept; he can withdraw it.",
|
||||
|
|
@ -494,6 +494,7 @@ fn variant(part: &Part) -> &'static str {
|
|||
Part::BrokeAfter { .. } => "broke_after",
|
||||
Part::Closed { .. } => "closed",
|
||||
Part::StillOpen { .. } => "still_open",
|
||||
Part::NowUndone { .. } => "now_undone",
|
||||
Part::Declined { .. } => "declined",
|
||||
Part::HeldFor { .. } => "held_for",
|
||||
Part::HoldBroken { .. } => "hold_broken",
|
||||
|
|
@ -503,7 +504,7 @@ fn variant(part: &Part) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
const VARIANTS: usize = 19;
|
||||
const VARIANTS: usize = 20;
|
||||
|
||||
const STRANGER: &str = "@stranger:example.org";
|
||||
|
||||
|
|
@ -532,14 +533,17 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
let search = || ReadName::of(&ReadRequest::Repo(format!("GameCult/Bifrost?q={s} plover")));
|
||||
let mut out: Vec<(Part, bool)> = vec![(Part::Said { room: MINDS.into(), text: w() }, true), (Part::Promise { room: MINDS.into(), text: w() }, true)];
|
||||
for reason in [Refusal::OverLines, Refusal::NoRoom, Refusal::NotQuotable, Refusal::SecondAmend] {
|
||||
out.push((Part::Refused { reason, room: room(), text: w() }, true));
|
||||
out.push((Part::Refused { reason, room: room(), text: w(), reach: false }, true));
|
||||
out.push((Part::Refused { reason, room: room(), text: w(), reach: true }, true));
|
||||
}
|
||||
out.push((Part::Refused { reason: Refusal::Echo, room: room(), text: w() }, false));
|
||||
out.push((Part::Refused { reason: Refusal::Echo, room: room(), text: w(), reach: false }, false));
|
||||
out.push((Part::Refused { reason: Refusal::Echo, room: room(), text: w(), reach: true }, false));
|
||||
for kind in [GapKind::Addressee, GapKind::Elsewhere, GapKind::MissingAffordance, GapKind::Unwritten] {
|
||||
out.push((Part::Gap { kind, room: room(), quote: Quote::Wrote(w()) }, true));
|
||||
out.push((Part::Gap { kind, room: room(), quote: Quote::Thought(w()) }, true));
|
||||
out.push((Part::Gap { kind, room: room(), quote: Quote::Wrote(w()), reach: false }, true));
|
||||
out.push((Part::Gap { kind, room: room(), quote: Quote::Thought(w()), reach: false }, true));
|
||||
}
|
||||
out.push((Part::Gap { kind: GapKind::Addressee, room: room(), quote: Quote::Sent }, false));
|
||||
out.push((Part::Gap { kind: GapKind::Addressee, room: room(), quote: Quote::Sent, reach: false }, false));
|
||||
out.push((Part::Gap { kind: GapKind::Elsewhere, room: room(), quote: Quote::Wrote(w()), reach: true }, true));
|
||||
for by_limit in [false, true] {
|
||||
out.push((Part::Unfinished { room: room(), text: w(), by_limit }, true));
|
||||
}
|
||||
|
|
@ -547,7 +551,7 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
out.push((Part::Amended { room: MINDS.into(), added: w(), promise }, true));
|
||||
}
|
||||
for refusal in [None, Some(EditRefusal::NotFound), Some(EditRefusal::NotHers), Some(EditRefusal::TooLong)] {
|
||||
out.push((Part::NotAmended { refusal, room: room(), added: w() }, true));
|
||||
out.push((Part::NotAmended { refusal, room: room(), added: w(), reach: false }, true));
|
||||
}
|
||||
out.push((Part::NoteLeft(w()), true));
|
||||
out.push((Part::NoteRefused(Refusal::Private), false));
|
||||
|
|
@ -575,8 +579,12 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
out.push((Part::StillOpen { reason, to: Some(who.clone()), words: w(), status, read: read.clone() }, true));
|
||||
}
|
||||
}
|
||||
out.push((Part::Declined { room: room(), text: w(), thought: w() }, true));
|
||||
out.push((Part::HeldFor { room: room(), askers: vec![who.clone()], text: w() }, false));
|
||||
out.push((Part::NowUndone { to: Some(who.clone()), words: w() }, true));
|
||||
out.push((Part::NowUndone { to: None, words: w() }, true));
|
||||
out.push((Part::Declined { room: room(), text: w(), thought: w(), reach: false }, true));
|
||||
out.push((Part::Declined { room: room(), text: w(), thought: w(), reach: true }, true));
|
||||
out.push((Part::HeldFor { room: room(), askers: vec![who.clone()], text: w(), reach: false }, false));
|
||||
out.push((Part::HeldFor { room: room(), askers: vec![who.clone()], text: w(), reach: true }, false));
|
||||
out.push((Part::HoldBroken { room: MINDS.into(), askers: vec![who.clone()] }, false));
|
||||
for (request, shows) in [
|
||||
(ReadRequest::Web(format!("https://example.org/{s}")), true),
|
||||
|
|
@ -640,7 +648,7 @@ fn k46_every_part_has_an_event_without_its_words() {
|
|||
fn k53_every_part_names_by_who() {
|
||||
const NAME: &str = "kestrel heron plover gannet skua";
|
||||
let parts = fixtures("ospreyledger", &person(NAME, None));
|
||||
let names_someone = |part: &Part| matches!(part, Part::Closed { .. } | Part::StillOpen { .. } | Part::HeldFor { .. } | Part::HoldBroken { .. });
|
||||
let names_someone = |part: &Part| matches!(part, Part::Closed { .. } | Part::StillOpen { .. } | Part::HeldFor { .. } | Part::HoldBroken { .. } | Part::NowUndone { to: Some(_), .. });
|
||||
assert!(parts.iter().filter(|(part, _)| names_someone(part)).count() > 20, "the rows with a person slot are listed");
|
||||
for pronouns in ["she/her", "he/him", "any"] {
|
||||
let her = crate::projection::select::forms(&json!({ "presentation": { "pronouns": pronouns } }));
|
||||
|
|
@ -682,3 +690,47 @@ fn k46_words_cannot_be_formatted_or_borrowed_as_text() {
|
|||
let () = <Words as NotDeref<_>>::probe();
|
||||
assert_eq!(format!("{:?}", Words::new("ospreyledger".into())), "Words(12 bytes)", "its Debug shows no words either");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K63 (map 16.33.5): one draft, one row; a draft that did not go out is one she had drafted.
|
||||
|
||||
/// A reach naming draft 1, as the Interpreter's gap carries it.
|
||||
fn reach_on_1(text: &str) -> Value {
|
||||
json!({ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text })
|
||||
}
|
||||
|
||||
/// A reach naming a draft some row tells is a clause of that row, whatever kept the draft back.
|
||||
#[test]
|
||||
fn k63_a_reach_is_a_clause_of_its_drafts_row() {
|
||||
let text = "I'll send the render tonight.";
|
||||
let clause = format!("It reaches for something he has no way to do from here. He had drafted: \"{text}\".");
|
||||
let refused = |reason: &str| json!({ "interpreter": { "room": MINDS, "said": [], "refused": [{ "act": "say", "draft": 1, "text": text, "reason": reason, "holds": [{ "who": "Meta", "id": "h1" }] }], "gaps": [reach_on_1(text)] }, "posted": [] });
|
||||
for (reason, row) in [("over_lines", "he had already sent two lines that turn."), ("undecided", "what was to become of it was never settled, so it was not sent."), ("not_quotable", "the line he meant to reply to is not one he can reply to here.")] {
|
||||
let (lines, omitted) = told(&refused(reason));
|
||||
assert_eq!(lines, [format!("- Nothing of this reached #minds:gamecult.org: {row} {clause}")], "{reason}: {omitted:?}");
|
||||
}
|
||||
// A held draft shows none of its words; the clause is still its own.
|
||||
assert_eq!(told(&refused("held")).0, ["- Nothing of this reached #minds:gamecult.org: Meta asked him to hold it, and it was not sent. It reaches for something he has no way to do from here."]);
|
||||
// An echo shows none either.
|
||||
assert_eq!(told(&refused("echo")).0, ["- Nothing reached #minds:gamecult.org. What he wrote was mostly the words he had just been sent, so none of it was sent. It reaches for something he has no way to do from here."]);
|
||||
let declined = json!({ "interpreter": { "room": MINDS, "said": [], "refused": [], "gaps": [reach_on_1(text)], "unsent": [{ "draft": 1, "how": "declined", "words": text, "quote": "Not tonight after all" }] }, "posted": [] });
|
||||
assert_eq!(told(&declined).0, [format!("- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"Not tonight after all\". {clause}")]);
|
||||
let elsewhere = json!({ "interpreter": { "room": MINDS, "said": [], "refused": [], "gaps": [reach_on_1(text), { "kind": "elsewhere", "from": "draft", "draft": 1, "words": text }] }, "posted": [] });
|
||||
assert_eq!(told(&elsewhere).0, [format!("- Nothing reached anyone. He meant this for another room or another time, and nothing carries it there; it arrives only if he sends it there. {clause}")]);
|
||||
// Two held refusals of one text are one row, and a reach on either is its clause.
|
||||
let twice = json!({ "interpreter": { "room": MINDS, "said": [], "refused": [{ "act": "say", "draft": 2, "text": text, "reason": "held", "holds": [] }, { "act": "say", "draft": 1, "text": text, "reason": "held", "holds": [] }], "gaps": [reach_on_1(text)] }, "posted": [] });
|
||||
let lines = told(&twice).0;
|
||||
assert!(lines.len() == 1 && lines[0].ends_with("It reaches for something he has no way to do from here."), "{lines:?}");
|
||||
}
|
||||
|
||||
/// A reach naming a draft no row tells (superseded) is its own row, as one she had drafted; a reach naming a line that went
|
||||
/// out is a promise, unchanged; and a reach in her thought is its own row beside it.
|
||||
#[test]
|
||||
fn k63_a_said_line_with_a_gap_keeps_both() {
|
||||
let text = "Missed you too. I'll send the render tonight.";
|
||||
let superseded = json!({ "interpreter": { "room": MINDS, "said": [], "refused": [], "gaps": [reach_on_1(text)], "unsent": [{ "draft": 1, "how": "superseded", "words": text, "quote": "Better to say it plainly" }] }, "posted": [] });
|
||||
assert_eq!(told(&superseded).0, [format!("- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. That he wanted it is kept in his record; no one has taken it up. He had drafted: \"{text}\".")]);
|
||||
let said = json!({ "interpreter": { "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [reach_on_1(text), { "kind": "missing_affordance", "from": "thought", "words": "I want to hear the kettle myself" }] }, "posted": [{ "event": "40", "room": MINDS, "text": text }] });
|
||||
let (lines, omitted) = told(&said);
|
||||
assert_eq!(lines, ["- Nothing happened. He reached for something he has no way to do from here, now or later, and it will not happen by itself. In his thought: \"I want to hear the kettle myself\". That he wanted it is kept in his record; no one has taken it up.".to_owned(), format!("- #minds:gamecult.org has, from him: \"{text}\". 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.")], "{omitted:?}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1999,10 +1999,14 @@ fn open_promises(inputs: &Inputs, her: Forms) -> (Vec<Promised>, String) {
|
|||
_ => String::new(),
|
||||
};
|
||||
// What an open promise needs read, exactly, and whether she has read that: her receipt on the entry (map 16.26,
|
||||
// 16.27). A search finds things and reads none, so a promise that needs one needs what it finds read.
|
||||
let reading = match (&promise.needs, promise.status.as_str()) {
|
||||
(Some(Needs::Read { request }), "open") if request.search() => format!(" It needs {} to read what {} finds, and {} {} not read that yet.", her.obj, request.what(her), her.subj, her.has),
|
||||
(Some(Needs::Read { request }), "open") => match crate::projection::commit::receipt(&promise.held) {
|
||||
// 16.27), or a read of this conversation that found it (K64). A search finds things and reads none, so a promise
|
||||
// that needs one needs what it finds read. A read made before the promise keeps it by what she has (K64).
|
||||
let read_here = |request: &crate::projection::read::ReadRequest| inputs.exchange.and_then(|exchange| exchange.tried.iter().find(|tried| tried.found && tried.key == request.normal())).map(|tried| tried.at);
|
||||
let before = promise.held["readBefore"]["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map(|at| at.with_timezone(&Utc));
|
||||
let reading = match (&promise.needs, promise.status.as_str(), before) {
|
||||
(Some(Needs::Words), "open", Some(at)) => format!(" {} read it {}, before this promise; what {} {} keeps it.", her.cap_subj, coarse(at, inputs.now), her.subj, her.has),
|
||||
(Some(Needs::Read { request }), "open", _) if request.search() => format!(" It needs {} to read what {} finds, and {} {} not read that yet.", her.obj, request.what(her), her.subj, her.has),
|
||||
(Some(Needs::Read { request }), "open", _) => match crate::projection::commit::receipt(&promise.held).or_else(|| read_here(request)) {
|
||||
Some(at) => format!(" It needs {} to read {}: {} read it {}.", her.obj, request.what(her), her.subj, coarse(at, inputs.now)),
|
||||
None => format!(" It needs {} to read {}, and {} {} not read it yet.", her.obj, request.what(her), her.subj, her.has),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2122,7 +2122,7 @@ fn k16_ten_parts_past_the_guard_are_counted_and_reported_never_dropped_silently(
|
|||
assert!(shown >= 1 && more >= 1, "{block}");
|
||||
assert_eq!(section.last().copied(), Some(format!("- {more} more things from her last turn are not shown here.").as_str()), "{block}");
|
||||
assert_eq!(packet.unshown.len(), more, "{:?}", packet.unshown);
|
||||
assert!(packet.unshown.iter().all(|line| line.starts_with("- Nothing of this reached") && line.contains(" She wrote: \"")), "{:?}", packet.unshown);
|
||||
assert!(packet.unshown.iter().all(|line| line.starts_with("- Nothing of this reached") && line.contains(" She had drafted: \"")), "{:?}", packet.unshown);
|
||||
assert!(packet.sections.bound.contains(&"outcome"));
|
||||
// The Projector's events carry no quote, so all ten fit its guard.
|
||||
assert_eq!(outcome_events(&packet), vec!["- Nothing of this reached #swarm:gamecult.org: she had already sent two lines that turn."; 10], "{}", packet.context);
|
||||
|
|
@ -2222,7 +2222,9 @@ fn a_gap_naming_an_echo_refused_draft_quotes_nothing_next_turn() {
|
|||
assert_eq!(decision["refused"][0]["reason"], "echo", "{kind}");
|
||||
let record = json!({ "interpreter": decision, "posted": [] });
|
||||
let told = outcome::outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(interpret::tests::packet().forms);
|
||||
assert!(told.len() == 2 && told.iter().all(|line| !line.contains(S)), "{kind}: {told:?}");
|
||||
// A reach is a clause of the echo's row (K63, one draft, one row); a routing gap is its own row.
|
||||
let rows = if kind == "missing_affordance" { 1 } else { 2 };
|
||||
assert!(told.len() == rows && told.iter().all(|line| !line.contains(S)), "{kind}: {told:?}");
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1);
|
||||
let projector = narrate::projector_prompt(&packet, &Tuning::default());
|
||||
assert!(!projector.contains(S) && !projector.contains("blue mat"), "{kind}: {projector}");
|
||||
|
|
@ -2781,7 +2783,7 @@ fn k43_x1_r1_her_decline_is_hers_to_read() {
|
|||
let room = Room { messages: vec![message(MINDS, "@heimdall:gamecult.org", "Heimdall", X1_HEIMDALL_R15, 2, true)], here: Some(MINDS.into()), ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1);
|
||||
// Golden: her view's outcome block and the Projector's outcome section.
|
||||
assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- Nothing of this reached {MINDS}: she chose not to send it. In her thought: {}. She wrote: {}.", select::spoken(X1_LIBBY_R15_THOUGHT), select::spoken(&draft)), "{}", packet.in_view);
|
||||
assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- Nothing of this reached {MINDS}: she chose not to send it. In her thought: {}. She had drafted: {}.", select::spoken(X1_LIBBY_R15_THOUGHT), select::spoken(&draft)), "{}", packet.in_view);
|
||||
assert_eq!(outcome_events(&packet), [format!("- Nothing of this reached {MINDS}: she chose not to send it.")], "{}", packet.context);
|
||||
let projector = narrate::projector_prompt(&packet, &Tuning::default());
|
||||
let section = packet.context.split("\nHere and now:\n").next().unwrap();
|
||||
|
|
|
|||
|
|
@ -282,6 +282,8 @@ mind_body::projection::harness: pub use super :: simulate :: simulate ;
|
|||
mind_body::projection::harness: struct Fixture # [derive (Clone , Debug)] pub-fields[her: String, names: Vec < String >, kind: TurnKind, now: DateTime < Utc >, here: Option < String >, operators: Vec < String >, minds: Vec < String >, last_heard: Vec < (String , u64) >]
|
||||
mind_body::projection::harness: struct Harness< 'a > pub-fields[instance: String, persona: Option < & 'a dyn PersonaSource >, model: Option < & 'a dyn Model >, tuning: PathBuf]
|
||||
mind_body::projection::harness: struct Message # [derive (Clone , Debug , Deserialize)] pub-fields[from: String, name: String, room: String, ago: Option < String >, round: Option < usize >, says: String, new: bool, tag: bool, mentions: Vec < String >, dm: bool, to: Option < String >, follow_up: bool, reply_to: Option < usize >]
|
||||
mind_body::projection::interpret: impl By
|
||||
mind_body::projection::interpret: impl DoneBy
|
||||
mind_body::projection::interpret: impl Drafts
|
||||
mind_body::projection::interpret: impl Faults
|
||||
mind_body::projection::interpret: impl GapKind
|
||||
|
|
|
|||
|
|
@ -1186,7 +1186,7 @@
|
|||
},
|
||||
"commitment": {
|
||||
"type": "object",
|
||||
"description": "One promise of hers. to: the Matrix id she promised, null for the room. event: her line's event id. status: open (she can keep it with what she has), blocked (she has no way to do it yet), kept, withdrawn or released. closedBy: the act that closed it, by its event; words only for an act of hers. needs: what keeping it needs (map 16.25.2): her words, a read of one thing, or something this body lacks. blockedBy: the read that found nothing and blocked it. reaffirmed: the newest three times she said it again. reopened: the newest three times her own words reopened a close (map 16.28.3). readAt, readId and readOf: when a read of what it needs last returned, which read, and what it read in normal form; a receipt whose readOf does not answer needs is none (map 16.26, 16.27).",
|
||||
"description": "One promise of hers. to: the Matrix id she promised, null for the room. event: her line's event id. status: open (she can keep it with what she has), blocked (she has no way to do it yet), kept, withdrawn or released. closedBy: the act that closed it, by its event; words only for an act of hers. needs: what keeping it needs (map 16.25.2): her words, a read of one thing, or something this body lacks. blockedBy: the read that found nothing and blocked it. reaffirmed: the newest three times she said it again. reopened: the newest three times her own words reopened a close (map 16.28.3). readAt, readId and readOf: when a read of what it needs last returned, which read, and what it read in normal form; a receipt whose readOf does not answer needs is none (map 16.26, 16.27). readBefore: a read of the same conversation that found what a read need named before the promise was made, so the need is her words (when, and what it read in normal form; map 16.33.5, K64).",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
@ -1352,6 +1352,23 @@
|
|||
"readOf": {
|
||||
"type": "string"
|
||||
},
|
||||
"readBefore": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"of": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"of"
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"$ref": "#/definitions/extensions"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue