From 84ea7b8e7d1426e0db9d4b49f0973d252ba499f1 Mon Sep 17 00:00:00 2001 From: iris Date: Thu, 16 Jul 2026 20:14:00 +0200 Subject: [PATCH] sweep: dedupe matrix ensure_all banner closure --- hive-c0re/src/main.rs | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/hive-c0re/src/main.rs b/hive-c0re/src/main.rs index 800c2934..26a98ec4 100644 --- a/hive-c0re/src/main.rs +++ b/hive-c0re/src/main.rs @@ -401,6 +401,21 @@ async fn cmd_serve( } } }); + /// Banner message for a failing matrix `ensure_all` sweep, shared by + /// both the initial and periodic `record_err` call sites below so the + /// wording can't drift between them. + fn matrix_sweep_banner(ctx: sweep_health::SweepFailure) -> String { + let age = ctx.since_last_ok.map_or_else( + || "no success this session".to_owned(), + |d| format!("last ok {} ago", sweep_health::fmt_age(d)), + ); + format!( + "matrix user/space sweep failing ({} consecutive, {age}) \ + — some agents may be missing matrix accounts, space membership, \ + or chat-room invites", + ctx.consecutive + ) + } // Matrix user sweep: same shape — ensure every container has // an account on the local matrix-tuwunel homeserver with an // access_token persisted to `/matrix-token`. No-op when @@ -422,18 +437,7 @@ async fn cmd_serve( if matrix::ensure_all().await { health.record_ok(); } else { - health.record_err(|ctx| { - let age = ctx.since_last_ok.map_or_else( - || "no success this session".to_owned(), - |d| format!("last ok {} ago", sweep_health::fmt_age(d)), - ); - format!( - "matrix user/space sweep failing ({} consecutive, {age}) \ - — some agents may be missing matrix accounts, space membership, \ - or chat-room invites", - ctx.consecutive - ) - }); + health.record_err(matrix_sweep_banner); } loop { tokio::select! { @@ -441,18 +445,7 @@ async fn cmd_serve( if matrix::ensure_all().await { health.record_ok(); } else { - health.record_err(|ctx| { - let age = ctx.since_last_ok.map_or_else( - || "no success this session".to_owned(), - |d| format!("last ok {} ago", sweep_health::fmt_age(d)), - ); - format!( - "matrix user/space sweep failing ({} consecutive, {age}) \ - — some agents may be missing matrix accounts, space membership, \ - or chat-room invites", - ctx.consecutive - ) - }); + health.record_err(matrix_sweep_banner); } } _ = matrix_shutdown.changed() => {