From 883fe34d6b3e915bbcfcdf1f47826cb8d7936eab Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 04:48:04 +0100 Subject: [PATCH] persona drain: pins on the owed window, the unknown of every send, and the wake rule over the owed waker Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/heartbeat/tests.rs | 16 ++++++++++++++++ crates/mind-body/src/persona/drain_tests.rs | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/crates/mind-body/src/heartbeat/tests.rs b/crates/mind-body/src/heartbeat/tests.rs index f0136d3..a397eac 100644 --- a/crates/mind-body/src/heartbeat/tests.rs +++ b/crates/mind-body/src/heartbeat/tests.rs @@ -1358,3 +1358,19 @@ fn t_l3_a_send_settled_starts_no_one() { let Outcome::Polled { launched } = rig.poll() else { panic!("held") }; assert!(launched.is_empty(), "{launched:?}"); } + +/// Soul s7 pins-on-new-lines. A line that wakes her and her trace does not hold decided starts her by the wake rule, which writes the claim for +/// the line; the owed waker is for a poll with nothing waking her, and does not take its place. +#[test] +fn t_l3_a_new_waking_line_is_woken_for_by_the_wake_rule_even_while_a_send_is_owed() { + let rig = quiet_rig(); + rig.say(ANN, delivery(1, "@op:chat", "Ann, please", &[])); + rig.poll(); + rig.end_unit(ANN); + rig.traces[ANN].rows.borrow_mut().push(serde_json::json!({ "held": ["$e1"], "owed": [{ "id": "l$e1:s0", "room": "!op", "text": "On it." }], "at": rig.now().to_rfc3339() })); + rig.say(ANN, delivery(2, "@op:chat", "Ann, again", &[])); + rig.advance(60); + let Outcome::Polled { launched } = rig.poll() else { panic!("held") }; + assert_eq!(launched, vec![Slug("ann".into())]); + assert!(rig.store.state.borrow().clone().unwrap().handled_mentions.contains(&"ann:$e2".to_owned()), "the new line's claim is written: the wake rule started her"); +} diff --git a/crates/mind-body/src/persona/drain_tests.rs b/crates/mind-body/src/persona/drain_tests.rs index a22dcb9..f53b72d 100644 --- a/crates/mind-body/src/persona/drain_tests.rs +++ b/crates/mind-body/src/persona/drain_tests.rs @@ -1199,3 +1199,21 @@ fn t_l3_a_start_that_cannot_rewrite_a_record_it_owes_fails_as_an_outage_the_poll assert_eq!(crate::projection::failed_run(&records).0, 1, "the poll backs off by a failed run: {records:?}"); assert!(records.last().is_some_and(|last| last["outage"] == true && last.get("strike").is_none()), "an outage, no strike: {records:?}"); } + +/// Soul s7 pins-on-new-lines. A send is repeated up to 1800 s after its record and no later (the least a homeserver remembers a transaction); +/// every send of a record past that is unknown, a record's several sends each; and a send past it is unknown even in a room an earlier unknown +/// has held, since it could never be repeated and would be owed for ever. +#[test] +fn t_l3_the_window_is_1800_seconds_and_every_send_past_it_is_unknown_even_in_a_held_room() { + let rig = Rig::new(vec![]); + owing_record(&rig, "n0-t0", 2500, &[("la:s0", &room(1), "one"), ("la:s1", &room(1), "two")]); + owing_record(&rig, "n1-t0", 2000, &[("lb:s0", &room(1), "three")]); + owing_record(&rig, "n2-t0", 1700, &[("lc:s0", &room(2), "inside")]); + rig.run(Never); + let rows: Vec = rig.trace.rows.borrow().iter().map(|(_, record)| record.clone()).collect(); + assert_eq!(rows[0]["unknown_sends"].as_array().map(Vec::len), Some(2), "both sends of the record: {}", rows[0]); + assert_eq!(rows[1]["unknown_sends"].as_array().map(Vec::len), Some(1), "past the window in a held room is unknown, not owed: {}", rows[1]); + assert!(rows[1].get("owed").is_none() && rows[0].get("owed").is_none(), "nothing past the window stays owed"); + assert!(texts(&rig, &room(1)).is_empty(), "nothing past the window was sent"); + assert_eq!(texts(&rig, &room(2)), ["inside"], "inside the window it is repeated"); +}