recv: hoist RECV_BATCH_MAX into hive-sh4re, drop magic 5 in wake hint
This commit is contained in:
parent
78396c8189
commit
be5b36911a
3 changed files with 17 additions and 10 deletions
|
|
@ -32,9 +32,9 @@ pub fn format_wake_prompt(
|
|||
String::new()
|
||||
} else {
|
||||
// Suggested batch size is clamped to the server-side recv cap
|
||||
// (see `RECV_BATCH_MAX` in hive-c0re) so the hint never asks
|
||||
// for more than one round-trip can deliver.
|
||||
let batch = unread.min(5);
|
||||
// so the hint never asks for more than one round-trip can
|
||||
// deliver.
|
||||
let batch = unread.min(u64::from(hive_sh4re::RECV_BATCH_MAX));
|
||||
format!(
|
||||
"\n\n({unread} more message(s) pending in your inbox — call `mcp__hyperhive__recv` \
|
||||
with `max: {batch}` to drain the next batch before acting. If the \
|
||||
|
|
|
|||
|
|
@ -149,13 +149,10 @@ async fn serve(stream: UnixStream, agent: String, coord: Arc<Coordinator>) -> Re
|
|||
/// positive `wait_seconds`.
|
||||
pub(crate) const RECV_LONG_POLL_MAX: std::time::Duration = std::time::Duration::from_mins(3);
|
||||
|
||||
/// Server-side hard cap on `Recv.max`. Bounds the size of a single
|
||||
/// round-trip so a confused caller can't drain the entire inbox in
|
||||
/// one go and blow past wire-buffer sizes; everything above the cap
|
||||
/// silently clamps. 5 keeps individual turns small — a big backlog
|
||||
/// is drained over several recv calls instead of one giant pop
|
||||
/// (#2150).
|
||||
pub(crate) const RECV_BATCH_MAX: u32 = 5;
|
||||
/// Server-side hard cap on `Recv.max` — canonical value lives in
|
||||
/// `hive_sh4re::RECV_BATCH_MAX` so the harness's wake-prompt hint and
|
||||
/// this enforcement site can't drift apart (#2150).
|
||||
pub(crate) const RECV_BATCH_MAX: u32 = hive_sh4re::RECV_BATCH_MAX;
|
||||
|
||||
pub(crate) fn recv_timeout(wait_seconds: Option<u64>) -> std::time::Duration {
|
||||
match wait_seconds {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,16 @@ pub mod paths;
|
|||
pub mod priv_proto;
|
||||
pub mod wire_time;
|
||||
|
||||
/// Server-side hard cap on `Recv.max` (see `AgentRequest::Recv`). Bounds
|
||||
/// the size of a single round-trip so a confused caller can't drain the
|
||||
/// entire inbox in one go and blow past wire-buffer sizes; everything
|
||||
/// above the cap silently clamps. 5 keeps individual turns small — a big
|
||||
/// backlog is drained over several recv calls instead of one giant pop
|
||||
/// (#2150). Lives here so both the enforcing side (hive-c0re's
|
||||
/// socket_server) and the hinting side (hive-ag3nt's wake prompt + tool
|
||||
/// docs) reference one constant instead of a scattered magic value.
|
||||
pub const RECV_BATCH_MAX: u32 = 5;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Host admin socket — /run/hyperhive/host.sock
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue