start_manager bound the same path register_agent binds. The migrate branch, hive-priv-sock::MANAGER_NAME and MANAGER_CONTAINER were no-ops or dead. The send allow-list docs promised a manager exemption the code never had. Tests that used ruth as the manager fixture use plain names.
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
//! Loose-ends aggregator. Assembles a `Vec<LooseEnd>` for a single agent
|
|
//! (`for_agent`) — always the caller's own. `Request::GetLooseEnds` from
|
|
//! an agent socket lands here. Reminders and todos are
|
|
//! agent-local (in-container `hive-agent` stores) and never sourced from
|
|
//! here.
|
|
//!
|
|
//! Call frequency is low (an agent doing self-introspection between
|
|
//! turns), so the sweep happens fresh every time — no caching, no
|
|
//! mutation events.
|
|
|
|
use anyhow::Result;
|
|
use hive_sh4re::inbox::LooseEnd;
|
|
|
|
use crate::coordinator::Coordinator;
|
|
|
|
/// Open threads pending against `agent`: undelivered inbox messages this
|
|
/// agent still owes itself a `recv` for, only when the count is non-zero.
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// Propagates errors from `count_pending`.
|
|
pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<LooseEnd>> {
|
|
let mut out = Vec::new();
|
|
// Only emitted when non-zero so a clean inbox doesn't add noise. The
|
|
// wake-message that drove the current turn is already delivered, so
|
|
// this counts only what's genuinely still queued.
|
|
let pending_messages = coord.broker.count_pending(agent)?;
|
|
if pending_messages > 0 {
|
|
out.push(LooseEnd::PendingMessages {
|
|
count: pending_messages,
|
|
});
|
|
}
|
|
Ok(out)
|
|
}
|