manager: add optional agent param to reminder RPCs

CountPendingReminders and ReminderRollup were hardcoded to
MANAGER_AGENT. Both now take agent: Option<String> — None keeps the
current behavior (manager's own), Some(name) returns that agent's
reminder stats. The broker functions already take an agent name, so
this is a thin wire-protocol change. Callers (web UI stats page,
post-turn counts) pass None.

Closes #122
This commit is contained in:
iris 2026-05-20 22:04:57 +02:00 committed by Mara
parent 01cbd5e7cc
commit 1f52746bd9
4 changed files with 19 additions and 7 deletions

View file

@ -343,7 +343,7 @@ async fn fetch_manager_post_turn_counts(socket: &Path) -> (Option<u64>, Option<u
}; };
let reminders = match client::request::<_, ManagerResponse>( let reminders = match client::request::<_, ManagerResponse>(
socket, socket,
&ManagerRequest::CountPendingReminders, &ManagerRequest::CountPendingReminders { agent: None },
) )
.await .await
{ {

View file

@ -529,6 +529,8 @@ async fn fetch_reminder_stats(socket: &std::path::Path, flavor: Flavor, window_s
socket, socket,
&hive_sh4re::ManagerRequest::ReminderRollup { &hive_sh4re::ManagerRequest::ReminderRollup {
since_secs: window_secs, since_secs: window_secs,
// Manager's own stats page — its own reminders.
agent: None,
}, },
) )
.await .await

View file

@ -409,16 +409,18 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
}, },
} }
} }
ManagerRequest::CountPendingReminders => { ManagerRequest::CountPendingReminders { agent } => {
match coord.broker.count_pending_reminders_for(MANAGER_AGENT) { let target = agent.as_deref().unwrap_or(MANAGER_AGENT);
match coord.broker.count_pending_reminders_for(target) {
Ok(count) => ManagerResponse::PendingRemindersCount { count }, Ok(count) => ManagerResponse::PendingRemindersCount { count },
Err(e) => ManagerResponse::Err { Err(e) => ManagerResponse::Err {
message: format!("{e:#}"), message: format!("{e:#}"),
}, },
} }
} }
ManagerRequest::ReminderRollup { since_secs } => { ManagerRequest::ReminderRollup { since_secs, agent } => {
match coord.broker.reminder_rollup_for(MANAGER_AGENT, *since_secs) { let target = agent.as_deref().unwrap_or(MANAGER_AGENT);
match coord.broker.reminder_rollup_for(target, *since_secs) {
Ok(stats) => ManagerResponse::ReminderRollup(stats), Ok(stats) => ManagerResponse::ReminderRollup(stats),
Err(e) => ManagerResponse::Err { Err(e) => ManagerResponse::Err {
message: format!("{e:#}"), message: format!("{e:#}"),

View file

@ -804,9 +804,13 @@ pub enum ManagerRequest {
#[serde(default)] #[serde(default)]
agent: Option<String>, agent: Option<String>,
}, },
/// Count of the manager's own pending reminders. Mirror of /// Count of pending reminders. `agent` selects whose: `None` =
/// the manager's own, `Some("<name>")` = that agent's. Mirror of
/// `AgentRequest::CountPendingReminders` on the manager surface. /// `AgentRequest::CountPendingReminders` on the manager surface.
CountPendingReminders, CountPendingReminders {
#[serde(default)]
agent: Option<String>,
},
/// Reminder statistics: counts of scheduled, delivered, and pending /// Reminder statistics: counts of scheduled, delivered, and pending
/// reminders (manager-flavour). Mirror of `AgentRequest::ReminderRollup`. /// reminders (manager-flavour). Mirror of `AgentRequest::ReminderRollup`.
ReminderRollup { ReminderRollup {
@ -814,6 +818,10 @@ pub enum ManagerRequest {
/// Pass 0 to include all reminders. /// Pass 0 to include all reminders.
#[serde(default)] #[serde(default)]
since_secs: u64, since_secs: u64,
/// Whose reminders to roll up: `None` = the manager's own,
/// `Some("<name>")` = that agent's.
#[serde(default)]
agent: Option<String>,
}, },
/// Manager-flavour self-introspection. Same wire shape as /// Manager-flavour self-introspection. Same wire shape as
/// `AgentRequest::Whoami`, but `role` is always `"manager"`. /// `AgentRequest::Whoami`, but `role` is always `"manager"`.