Persona live organ: one-turn, drain, wake-humans-pace, turn memory (squash of hands/persona-live-drain) #83
5 changed files with 26 additions and 14 deletions
persona tests: the told items come from the one derivation; the untold items of her trace, stamped once, kept on rewrite
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
263c903508
|
|
@ -1150,7 +1150,7 @@ fn t_l3_an_unknown_send_is_told_at_her_next_real_turn_exactly_once_though_a_line
|
|||
assert_eq!(set_aside(&rig), aside, "the struck line was set aside before the turn");
|
||||
let all = records(&rig);
|
||||
let before_turn: Vec<Value> = all.iter().filter(|record| record["room"] != json!(room(3))).cloned().collect();
|
||||
let told = |records: &[Value]| crate::projection::history(records).last_outcome.map(|last| last["unknown"].clone());
|
||||
let told = |records: &[Value]| crate::projection::history(records).last_outcome.map(|last| last["untold"].clone());
|
||||
assert_eq!(told(&before_turn), Some(json!([{ "room": MINDS, "text": rig.mouth.sent.borrow()[0].text }])), "aside={aside}: told at her next turn");
|
||||
rig.run(scripted(false));
|
||||
assert_eq!(told(&records(&rig)), Some(Value::Null), "aside={aside}: told once");
|
||||
|
|
@ -1418,7 +1418,7 @@ fn t_l3_a_refusal_answered_to_a_resend_is_unknown_and_told_and_to_a_first_send_i
|
|||
assert!(rows[0]["refused_sends"] == json!([]) && rows[0].get("owed").is_none(), "{}: not told as unsent: {}", refusal.name(), rows[0]);
|
||||
assert_eq!(rows[1]["refused_sends"][0]["refusal"], refusal.name(), "a first send stays refused: {}", rows[1]);
|
||||
assert!(rows[1].get("unknown_sends").is_none());
|
||||
assert!(crate::projection::history(&rows).last_outcome.is_some_and(|last| last["unknown"][0]["text"] == "handed over"), "she is told it is unknown");
|
||||
assert!(crate::projection::history(&rows).last_outcome.is_some_and(|last| last["untold"][0]["text"] == "handed over"), "she is told it is unknown");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
let room = words(&item["room"]);
|
||||
match (item["kind"].as_str(), words_of(&item["text"])) {
|
||||
(Some("unknown"), Some(text)) => outcome.parts.push(Part::Unknown { room, text }),
|
||||
(Some("unsent"), Some(text)) => outcome.parts.push(Part::Unsent { room, text, reach: false }),
|
||||
(Some("refused"), Some(text)) => outcome.parts.push(Part::Unsent { room, text, reach: false }),
|
||||
(Some("set_aside"), text) => outcome.parts.push(Part::SetAside { room, line: words(&item["sender"]).zip(text) }),
|
||||
(Some("not_kept"), _) => outcome.parts.push(Part::NotKept),
|
||||
_ => outcome.omitted.push(format!("an untold item she cannot be told truly: {item}")),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ fn told(record: &Value) -> (Vec<String>, Vec<String>) {
|
|||
(outcome.lines(packet().forms), outcome.omitted)
|
||||
}
|
||||
|
||||
/// What she is told after `record` alone is her trace: the items it holds that she has not been told come from the one derivation, not from the record's own fields.
|
||||
fn outcome_trace(record: &Value) -> Outcome {
|
||||
crate::projection::history(std::slice::from_ref(record)).last_outcome.and_then(|last| outcome_of(&last)).expect("a record")
|
||||
}
|
||||
|
||||
fn told_trace(record: &Value) -> (Vec<String>, Vec<String>) {
|
||||
let outcome = outcome_trace(record);
|
||||
(outcome.lines(packet().forms), outcome.omitted)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_that_went_out_is_told_as_the_room_having_it() {
|
||||
let (lines, omitted) = told(&record("I nod. <typed>Hi Nibu.\n\nGood tag.</typed>", json!({ "say": [{ "draft": 1 }], "gaps": [] }), &["Hi Nibu.\n\nGood tag."]));
|
||||
|
|
@ -632,23 +642,23 @@ fn t6_a_refused_send_is_told_as_not_gone_out() {
|
|||
let refused = |posted: Value, gaps: Value| {
|
||||
let mut record = record(&format!("<typed>{text}</typed>"), json!({ "say": [{ "draft": 1 }], "gaps": gaps }), &[]);
|
||||
record["posted"] = posted;
|
||||
record["refused_sends"] = json!([{ "room": MINDS, "text": text, "in_reply_to": "$gone", "refusal": "reply_target_not_in_room" }]);
|
||||
record["refused_sends"] = json!([{ "room": MINDS, "text": text, "in_reply_to": "$gone", "refusal": "reply_target_not_in_room", "at": "2026-11-27T10:00:00Z" }]);
|
||||
record
|
||||
};
|
||||
let (lines, omitted) = told(&refused(json!([]), json!([])));
|
||||
let (lines, omitted) = told_trace(&refused(json!([]), json!([])));
|
||||
assert_eq!(lines, [format!("- He had drafted {}, and it did not go out.", crate::projection::select::spoken(text))], "{omitted:?}");
|
||||
assert!(omitted.is_empty(), "{omitted:?}");
|
||||
let outcome = outcome_of(&refused(json!([]), json!([]))).unwrap();
|
||||
let outcome = outcome_trace(&refused(json!([]), json!([]))).unwrap();
|
||||
assert_eq!(outcome.event(0, packet().forms, &[]), "- He had drafted a line, and it did not go out.");
|
||||
let (reach, _) = told(&refused(json!([]), json!([{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }])));
|
||||
let (reach, _) = told_trace(&refused(json!([]), json!([{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }])));
|
||||
assert_eq!(reach, [format!("- He had drafted {}, and it did not go out. It reaches for something he has no way to do from here.", crate::projection::select::spoken(text))]);
|
||||
// The receipt decides what reached the room: a line with one is told as the room having it, whatever else says not.
|
||||
let (lines, _) = told(&refused(json!([{ "event": "40", "room": MINDS, "text": text }]), json!([])));
|
||||
let (lines, _) = told_trace(&refused(json!([{ "event": "40", "room": MINDS, "text": text }]), json!([])));
|
||||
assert!(lines.iter().all(|line| !line.contains("did not go out")), "{lines:?}");
|
||||
// Mutant (match a refused send by text alone): a refusal in another room tells nothing here.
|
||||
let mut elsewhere = refused(json!([]), json!([]));
|
||||
elsewhere["refused_sends"][0]["room"] = json!("#elsewhere:gamecult.org");
|
||||
let (lines, omitted) = told(&elsewhere);
|
||||
let (lines, omitted) = told_trace(&elsewhere);
|
||||
assert!(lines.is_empty() && omitted[0].contains("no receipt"), "{lines:?} {omitted:?}");
|
||||
}
|
||||
|
||||
|
|
@ -656,9 +666,10 @@ fn t6_a_refused_send_is_told_as_not_gone_out() {
|
|||
fn a_put_refused_twice_and_a_set_aside_line_are_told_plainly() {
|
||||
let mut refused = record("<typed>Hi Nibu.</typed>", json!({ "say": [{ "draft": 1 }], "gaps": [] }), &["Hi Nibu."]);
|
||||
refused["put_refused"] = json!("stale again");
|
||||
assert_eq!(told(&refused).0, ["- What he meant to keep from that turn was not kept.", "- #minds:gamecult.org has, from him: \"Hi Nibu.\"."], "the refusal's words are the mind's, not hers: she is told only that it was not kept");
|
||||
refused["put_refused_at"] = json!("2026-11-27T10:00:00Z");
|
||||
assert_eq!(told_trace(&refused).0, ["- What he meant to keep from that turn was not kept.", "- #minds:gamecult.org has, from him: \"Hi Nibu.\"."], "the refusal's words are the mind's, not hers: she is told only that it was not kept");
|
||||
let aside = json!({ "set_aside": [{ "room": MINDS, "event": "$e1", "sender": "Nibu", "text": "are you there" }], "at": "2026-11-27T10:00:00Z" });
|
||||
assert_eq!(told(&aside).0, ["- Nothing reached #minds:gamecult.org. His turn on Nibu's line \"are you there\" failed twice, so it was set aside."]);
|
||||
assert_eq!(told_trace(&aside).0, ["- Nothing reached #minds:gamecult.org. His turn on Nibu's line \"are you there\" failed twice, so it was set aside."]);
|
||||
let unnamed = json!({ "set_aside": [{ "room": MINDS, "event": "$e1" }], "at": "2026-11-27T10:00:00Z" });
|
||||
assert_eq!(told(&unnamed).0, ["- Nothing reached #minds:gamecult.org. His turn on a line there failed twice, so it was set aside."]);
|
||||
assert_eq!(told_trace(&unnamed).0, ["- Nothing reached #minds:gamecult.org. His turn on a line there failed twice, so it was set aside."]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ fn untold(records: &[Value]) -> Vec<Value> {
|
|||
let fresh = |stamp: &Value| at(stamp).is_some_and(|made| last_start.is_none_or(|start| start <= made));
|
||||
let mut told = Vec::new();
|
||||
for record in records.iter().filter(|record| record.get("failed").is_none()) {
|
||||
for (kind, field) in [("unknown", "unknown_sends"), ("unsent", "refused_sends")] {
|
||||
for (kind, field) in [("unknown", "unknown_sends"), ("refused", "refused_sends")] {
|
||||
told.extend(record[field].as_array().into_iter().flatten().filter(|sent| fresh(&sent["at"])).map(|sent| json!({ "kind": kind, "room": sent["room"], "text": sent["text"] })));
|
||||
}
|
||||
if fresh(&record["at"]) {
|
||||
|
|
|
|||
|
|
@ -399,7 +399,8 @@ fn t_l3_past_the_window_a_handed_send_is_unknown_and_one_never_handed_is_refused
|
|||
let mut record = json!({ "owed": [{ "id": "k:s0", "room": "!a:b", "text": "handed", "handed": true }, { "id": "k:s1", "room": "!c:d", "text": "never" }], "posted": [], "refused_sends": [], "edited": [] });
|
||||
deliver(&mouth(&chat), &mut record, Pass::Past, Utc::now(), &mut BTreeSet::new(), &mut |_| true);
|
||||
assert!(chat.sent.borrow().is_empty(), "nothing is made past the window");
|
||||
assert_eq!(record["unknown_sends"], json!([{ "room": "!a:b", "text": "handed" }]));
|
||||
assert_eq!(record["unknown_sends"].as_array().map(|sends| sends.iter().map(|sent| (sent["room"].clone(), sent["text"].clone())).collect::<Vec<_>>()), Some(vec![(json!("!a:b"), json!("handed"))]));
|
||||
assert!(record["unknown_sends"][0]["at"].is_string() && record["refused_sends"][0]["at"].is_string(), "each is stamped when it is made: {record}");
|
||||
assert_eq!(record["refused_sends"][0]["refusal"], "not_sent_past_the_window");
|
||||
assert!(record.get("owed").is_none());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue