Projector: a table without her row says so, whether or not its age is known

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 00:34:03 +01:00
commit c43385962f
2 changed files with 6 additions and 4 deletions

View file

@ -146,9 +146,9 @@ fn own_addressee(addressing: Option<&dyn HeartbeatView>, own_sender: &str, publi
let why = match (&table, written_at) {
(None, _) => "no heartbeat addressing is configured (MIND_HEARTBEAT_STATE is not set)".to_owned(),
(Some(Err(fault)), _) => format!("the heartbeat addressing could not be read: {fault:#}"),
(Some(Ok(_)), None) => "there is no heartbeat file".to_owned(),
(Some(Ok(Some(_))), _) => "the heartbeat's addressing table has no row for her".to_owned(),
(Some(Ok(None)), None) => "there is no heartbeat file".to_owned(),
(Some(Ok(None)), Some(_)) => "the heartbeat file holds no addressing table".to_owned(),
(Some(Ok(Some(_))), Some(_)) => "the heartbeat's addressing table has no row for her".to_owned(),
};
(Addressee::new(own_sender, [localpart(own_sender), public_name]), report("own names only", &why))
}

View file

@ -1287,8 +1287,10 @@ fn the_report_says_how_old_the_addressing_table_is_and_why_it_was_not_used() {
let written = now() - chrono::Duration::minutes(90);
let with_her = run(&Stale(Some(crate::heartbeat::Addressing { minds: vec![hers] }), Some(written)));
assert_eq!((with_her["source"].as_str(), with_her["age_minutes"].as_i64()), (Some("heartbeat"), Some(90)));
let without_her = run(&Stale(Some(crate::heartbeat::Addressing { minds: vec![other] }), Some(written)));
assert!(without_her["why"].as_str().unwrap().contains("no row for her"), "{without_her}");
for written_at in [Some(written), None] {
let without_her = run(&Stale(Some(crate::heartbeat::Addressing { minds: vec![other.clone()] }), written_at));
assert!(without_her["why"].as_str().unwrap().contains("no row for her"), "a table without her is that, whatever its age: {without_her}");
}
let no_file = run(&Stale(None, None));
assert!(no_file["why"].as_str().unwrap().contains("no heartbeat file") && no_file["age_minutes"].is_null(), "{no_file}");
let no_table = run(&Stale(None, Some(written)));